WooCommerce-Logo

[AWD Weight Shipping for WooCommerce] not Working with Woocommerce 2.1.0

I’ve submitted a new plugin to WordPress.org, you can download it here [Woocommerce Weight & Country Based Shipping Plugin]

↑ ↑ ↑ ↑ ↑ ↑ Stop here, use the plugin above↑ ↑ ↑ ↑ ↑ ↑


[AWD Weight/Country Shipping for WooCommerce Plugin] Not Compatible with Woocommerce since V 2.1.0

This quick fix works for Woocommerce V 2.1.0 ~ 2.1.6

Weight Base Shipping option not shows up on cart, and error_log file generated on root directory of site.

The error_log says:

[11-Feb-2014 09:26:13 UTC] PHP Warning:  in_array() expects parameter 2 to be array, null given in /wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-shipping-method.php on line 189
 [11-Feb-2014 09:26:37 UTC] PHP Warning:  array_intersect() [<a href='function.array-intersect'>function.array-intersect</a>]: Argument #1 is not an array in /wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-shipping-method.php on line 179

The cause is that Woocommerce changed many code in this new release.

Here is a temporary fix for this problem.

  1. Download : abstract-wc-shipping-method.zip
  2. Extact, you will get a file abstract-wc-shipping-method.php
  3. upload to /wp-content/plugins/woocommerce/includes/abstracts/  and override the file with same name.

That’s it !

AWD Weight Shipping for WooCommerce

AWD Weight Shipping for WooCommerce

 

Changes I made in this file (in Bold):

    /**
     * is_available function.
     *
     * @param array $package
     * @return bool
     */
    public function is_available( $package ) {
        if ( $this->enabled == "no" )
            return false;

        // Country availability
        switch ( $this->availability ) {
            case 'specific' :
            case 'including' :
if ( is_array( $this->countries ) ) :  //Add            
                $ship_to_countries = array_intersect( $this->countries, array_keys( WC()->countries->get_shipping_countries() ) );
            break;
endif;   //Add            
            case 'excluding' :
if ( is_array( $this->countries ) ) :  //Add
                $ship_to_countries = array_diff( $this->countries, array_keys( WC()->countries->get_shipping_countries() ) );
            break;
endif;   //Add        
            default :
                $ship_to_countries = array_keys( WC()->countries->get_shipping_countries() );
            break;
        }

if ( is_array( $ship_to_countries ) ) :  //Add
        if ( ! in_array( $package['destination']['country'], $ship_to_countries ) )
            return false;
endif;   //Add

        return apply_filters( 'woocommerce_shipping_' . $this->id . '_is_available', true, $package );
    }

  46Comments

  1. Kyaviger   •  

    It’s not working when only one product is in cart. Or better said it’s not calculating. It’s like it’s using native woocoomerce function for shipping. Numbers depends on cost of that one product. This happens only with one product in cart.

  2. Kevin   •  

    Hello,

    The plugin not work with Woocommerce 2.2.8 …
    Any solution ?

  3. Boyko   •  

    Great job! Thank`s for the perfect plugin!

  4. Paul   •  

    your tweaks have been a godsend for me every time there’s been an update to woocommerce but I haven’t been able to get it to work with the latest update to woocommerce 2.1.9 (wordpress 3.9.1).

    Seems the woocommerce folders have all been shuffled about with the new update – found the file in the abstracts folder, applied your changes which have always worked great previously, but hasn’t done so this time round.

    Would really appreciate your help to get it back working again! hope to see if there’s a solution once you’ve checked out the woocommerce update.

    • Paul   •  

      IGNORE ME!/DELETE COMMENT!! I was updating the wrong file in the wrong folder on the wrong domain!!! your fix still works a treat! :-)

  5. Andrew Vajda   •  

    Thank you so much for your brilliant fix! you are a saint amongst men! May your present and future be filled with success, love and happiness!!! :) You rock!!!!!

  6. Beck   •  

    Thank goodness I found your page with the shipping fix. Ive spent days trying to get my shipping calculator to work.
    Great work!

  7. Eric   •  

    Thank you!!!

  8. David Glez   •  

    Hey guy,

    thanks you for your post, is great.

    Regars!

  9. Rachel   •  

    Just want to give Jerrif a massive thank you for sorting out the problem I was having (I’d used / and not | in the shipping rates definition.

    You’re an absolute legend :)

  10. Rachel   •  

    Hi Jeriff,

    I tried to install your patch for AWD but it didn’t work so I installed your weight based plugin. When you go to checkout, you’re asked to “Please fill in your details to see available shipping methods.” I’ve tried with my details and with someone else’s but still no luck. Do you know what I could be doing wrong? I really need some help on this, I’m not very technical and my site has been down for over a week now. Please help me!!

    Many thanks in advance,
    Rachel

  11. Paul   •  

    rarely leave comments on any website but had to say a huge THANK YOU for providing this valuable info and making AWD work with woo commerce! This really is the only way to calculate shipping and really should come as standard with woocommerce. THANKS AGAIN!!

  12. Dale   •  

    I used the works like a charm, thank you :)

  13. chika   •  

    please is there another alternative to edit this apart from ftp

  14. chika   •  

    i need help. am a complete newbie..i stuck. i have the awd weight plugin that doesn’t work, but worse still my ftp isn’t working either, keeps failing. is there another way round this. Being on this for hours.!!!!!

    please help..thanks

    • DrFrankenskein   •  

      You need to go to the Woocommerce plugin, go to edit, and then navigate to the folder where the file is….open up Jeriff’s file. Copy its contents and then replace all of the text in the woocommerce file that Jeriff specifies.

      Viola. Done. You won’t need to bother with a FTP server or login. You can do it all from your WP control panel.

  15. Anon   •  

    Thank you so much. I removed the weight based plugin a while ago now and was still left with this problem. You’ve saved me so much work.

  16. Chris Furness   •  

    Brilliant, works a treat. Thanks for sharing.

    Chris

  17. Sarah   •  

    THANK YOU!
    Best fix!

  18. Stéph   •  

    Thanks again, your fix works with woocommerce 2.1.5

  19. Shei   •  

    Thanks so much Jeriff, great fix big help :)

  20. Mark   •  

    Great fix, works with woocommerce 2.1.3

  21. eric   •  

    just to add my bit of thanks – for posting the fix to the shipping plugin that makes my woo-commerce work..
    And i would agree,it would be fantastic to get a more permanent update for this plugin. I know you are not the plugin author, but you are making it work for us – thank you

  22. Barry Laminack   •  

    This worked great Jeff, thanks so much!

  23. Chris   •  

    Would be fantastic to see a fully working updateable version of this plugin compatible with WooCom 2.1. I really hope you can put something together! Cheers.

  24. Andreas   •  

    Thank you Jeriff! What a kind thing to do for us. It seems to work well with 2.1.2 as well, even though I’ve only tested on 1 product for a couple of minutes.

  25. Alan Johnson   •  

    Great fix. Thank you very much. You have saved me hours of grief!

    I would be very interested in a new plugin that is compatible with the latest WooCommerce!

  26. Mumfy   •  

    Looks like it’s working after all. Maybe I was too impatient. Seems it does take a while before it actually shows up.

    So a very big thanks and a big hug, darling ;-) for this quick fix!!

    Petra

  27. Menathor   •  

    Hi Jeriff! Great work on making a patch so quickly. One question – this patch changes the WooCommerce core files, which will be overwritten every time there is an upgrade.

    Will you make a permanent fix in the next version of AWD which doesn’t need this patch?

  28. Stéph   •  

    It works also with the new version of woocomerce 2.1.2 if you have udpate like me this version !
    Thanks again Jeriff !

    • Jeriff Cheng   •     Author

      OMG, Woo-commerce is going crazy. Upgrading rapidly…

  29. Stéph   •  

    Thank you very much, now, it works cery well :)

  30. Deb   •  

    Thank you so much for this easy fix!! Really appreciate you posting that as I had customers contacting me. You’re awesome! :)

  31. Neal   •  

    Thank you Jeriff so much for this … been tearing my hair (what’s left) after updating to WooCommerce 2.1 – the fix seems to work perfectly so far. Will do more testing too.

    Much gratitude.

  32. Blazej   •  

    Works now. Thanks! :-)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>