• Resolved akshat05

    (@akshat05)


    Hi,

    I used the following snippet to set the COD orders on hold, it’s working fine but the instructions (Pay with cash upon delivery.) are written twice on the thank you page and in emails.

    add_filter( 'woocommerce_payment_gateways', 'my_core_gateways',30,1 );
    function my_core_gateways( $methods ) {
    	$methods[] = 'WC_Gateway_COD_custom';
    	return $methods;
    }
    
    class WC_Gateway_COD_custom extends WC_Gateway_COD {
    	public function process_payment( $order_id ) {
    
    		$order = wc_get_order( $order_id );
    
    		// Mark as on-hold
    		$order->update_status( 'on-hold', __( 'Payment to be made upon delivery.', 'woocommerce' ) );
    
    		// Reduce stock levels
    		$order->reduce_order_stock();
    
    		// Remove cart
    		WC()->cart->empty_cart();
    
    		// Return thankyou redirect
    		return array(
    			'result'    => 'success',
    			'redirect'  => $this->get_return_url( $order )
    		);
    	}
    }

    Kindly help me in resolving this.

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Payment instructions appearing twice’ is closed to new replies.