Woocommerce Advanced Shipping - Using Custom Matching Condition

wordpress

#1

Hello everyone. This is my first post here so I apologize if I do not do it correctly. I am using Woocommerce Advanced Shipping plugin on a winery website to programmatically offer penny (0.01USD) shipping for orders with 6 or more bottles (as it is efficient to ship in multiples of 6). However, this client offers products that include 2 or 3 bottles. The quantity condition does not work for me because a three-bottle product counts as a single product when calculated for quantity.

I have begun trying to write a custom condition function as the guide here explains: http://docs.shopplugins.com/article/41-developer-adding-a-custom-condition

I feel like I am getting close, but it still does not work. Here is my code: http://pastebin.com/1ZMj4W7F

I am very familiar with developing for WordPress but not so much Woocommerce. I have been emailing back and forth with the plugin creator but I don’t know if he wants to support custom code (at least without charging). Can anyone take a look at my code and help me out?

Here’s what I’ve done:

  1. Set up custom attributes called ‘bottles’ on every product. On products with three bottles, the value is 3, and so on.
  2. Created the custom functions listed in my pastebin.
  3. Created the custom conditional statement within the Woocommerce Advanced Shipping plugin settings page.

Any help is gratefully appreciated. Thanks all!


#2

Hey Josiah,

I oficially don’t support (creating) custom code for WooCommerce Advanced Shipping, but I’m more then happy to see if I can help if initial efforts are already done.

I’ve taken a look at your code and made some changes: http://pastebin.com/rDeDTNa7
Haven’t tested it, bi it should be working/close.

Wasn’t sure what wasn’t working so its harder to focus on one part then. (my most significant change would be in the matching function filter name, it was
was_match_condition_bottles, changed it to was_match_condition_bottlenum to match the condition slug.

Hope that helps :smile:
Cheers,
Jeroen Sormani


#3

Hi Jeroen,

Thanks for your reply! I’ve adapted my code to use the updates you made, but I seem to still be having issues.

Here is my latest code: http://pastebin.com/GZYRN9Lu

PHP can be frustrating because of how hard it is to see exactly where the code is failing. It seems as though when the condition is matched, my cart doesn’t display anything. Only when it isn’t matched it shows the cart.

Thank you for your help and I am very grateful if you can continue offering help.

Thank you,

Josiah