WordPress.org

Forums

WooCommerce - excelling eCommerce
[resolved] Shipping Charges according Order (2 posts)

  1. Supriya_Kadam
    Member
    Posted 1 year ago #

    hi,
    I am using WooCommerce 2.0.20 it works fine. How to check order contain different category products or not ? because states are my product categories and if customer order have different category product then he/she pay more as a shipping charges. for e.g. if my product categories are 'abc','pqr' and customer order 1 product from 'abc' and another from 'pqr' then he/she pay extra X amount as shipping charge. If order all product from either 'abc' or 'pqr' then he/she not pay extra amount. Please help me to solve my problem ....

    https://wordpress.org/plugins/woocommerce/

  2. Supriya_Kadam
    Member
    Posted 1 year ago #

    Finally i got answer...

    If you add different shipping charges according to product category then you need to create shipping classes. Add those shipping classes with amount in additional rate which in Woocommerce->Shipping -> Flat Shipping
    tab.
    And according to your condition you can hide or show shipping classes.
    To hide or show shipping class you can write code in your theme function.php Also you show only one method which satisfy your condition.

    e.g. If i want to hide other shipping method when shipping method are available then code become

    // Hide standard shipping option when free shipping is available
    add_filter( 'woocommerce_available_shipping_methods', 'hide_standard_shipping_when_free_is_available' , 10, 1 );
    
    /**
     *  Hide Standard Shipping option when free shipping is available
     *
     * @param array $available_methods
     */
    function hide_standard_shipping_when_free_is_available( $available_methods ) {
    
        if( isset( $available_methods['free_shipping'] ) AND isset( $available_methods['flat_rate'] ) ) {
    
            // remove standard shipping option
            unset( $available_methods['flat_rate'] );
        }
    
        return $available_methods;
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce - excelling eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic