WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
Default shipping method for Payment method (3 posts)

  1. Lodir17
    Member
    Posted 10 months ago #

    Hello

    Is there a possibility to use a default shipping method for a chosen payment method -

    I am using a multi-step checkout process. The payment method selection is BEFORE the order overview table (where you can select shipping). I would like to use Cash on delivery on the payment method and display only Local delivery on the shipping selection page. Is this possible?

    Currently when I select COD I can select both flat rate and local pickup shipping. I need to use flat rate for other ways of payment/delivery.

    Thank you in advance

    http://wordpress.org/plugins/woocommerce/

  2. Lodir17
    Member
    Posted 10 months ago #

    I think this is not possible so I'm trying a different approach - I'm trying to copy "Enable for shipping methods" field from COD to BACS -

    function is_available() {
    		global $woocommerce;
    
    		if ( ! empty( $this->enable_for_methods ) ) {
    
    			if ( is_page( woocommerce_get_page_id( 'pay' ) ) ) {
    
    				$order_id = (int) $_GET['order_id'];
    				$order = new WC_Order( $order_id );
    
    				if ( ! $order->shipping_method )
    					return false;
    
    				$chosen_method = $order->shipping_method;
    
    			} elseif ( empty( $woocommerce->session->chosen_shipping_method ) ) {
    				return false;
    			} else {
    				$chosen_method = $woocommerce->session->chosen_shipping_method;
    			}
    
    			$found = false;
    
    			foreach ( $this->enable_for_methods as $method_id ) {
    				if ( strpos( $chosen_method, $method_id ) === 0 ) {
    					$found = true;
    					break;
    				}
    			}
    
    			if ( ! $found )
    				return false;
    		}
    
    		return parent::is_available();
    	}

    I'm using this snippet - I select the "Local pickup" in the "Enabled for shipping methods" field in BACS, but it doesn't disable Local pickup.

    Any ideas?
    Thanks in advance!

  3. Re4DeR
    Member
    Posted 7 months ago #

    do you solve it?

Reply

You must log in to post.

About this Plugin

About this Topic