WooCommerce updating the shipping method depending on the shipping choice field changes - woocommerce

In my online store, there are sevral shipping methods. I added a plugin for distance delivery (Boxtal Connect)
I would like to be able to autorefresh total amount when a new shipping method is chose on the checkout page.
I think the selector is name=shipping_method[0] and the trigger is jQuery('body').trigger('update_checkout',
I would like to find an code to add on my child function.php to do it.
In fact it works well on the cart page and I think it is a native woocommerce function.
Thanks for you help

Related

WooCommerce Multi-Step Checkout (Billing/Shipping Address and Payment Methods on different pages)

I'm currently working on a multi STRIPE checkout for different STRIPE accounts based on the shipping country.
So far everything works smoothly by using the wc_stripe_params, wc_stripe_payment_request_params and woocommerce_stripe_request_headers filters and overloading the respective classes for the webhooks. There is one problem though.
Upon checkout page load, where the payment methods are, STRIPE renders CDATA values for their JS files.
When the initial shipping country guess through geoip database was correct and the customer doesnt change the shipping country, everything works fine, since the correct public keys were inserted into the JS of STRIPE. When the customer changes the shipping country there is no way to manipulate the already processed JS variables. This is why I want to split up the checkout process so that the last page is just for payment options based upon the before selected shipping country.
I know that there are multiple plugins for multi-step checkout available, but all use ajax for a smooth rendering, which results in the same error. I understand the way how to customize different processes in WP or WC, but I don't know how to really tackle this one since the formon the checkout page is posted to the wc_get_checkout_url() which needs payments selected and done - it doesnt look like there is a real multi step without ajax planned?
Thanks in advance for any help or thoughts
Problem solved by splitting up the checkout process into multiple forms and posting the data as one to the woocommerce checkout controller

Customizing Woocoomerce Cart page

Hi I want to add checkbox on my Cart page of woocommerce when user check the box it will automatically subscribe them for my product. I have bought woocommerce subcriber plugin but I don't know how to add checkbox which will have this functionality in cart page.
I will try to answer to the best of my knowledge given that I am not proficient with woocommerce. But the general idea is that, you add your checkbox on the cart page of the theme and pass the the value via form data(like name="subscribe" value="True/false") to the data handler(most probably the next page in the checkout cycle which would be delivery or payment options page), which will then call the plugin and pass the subscriber info to it. I would say that it would make sense to put the checkbox where you collect customer info but hey your site, your choice.
Sorry if this is a very generic answer and not a detailed one. I am very new to this myself. Best of luck.

WooCommerce - Apply coupon of discounts of a given payment method

I'm integrating a solution with WooCommerce where a coupon of discount is given depending on the payment method that customer chooses. So, to do it, the coupon needs to be created/applyed in checkout page, when customer is selecting the payment method he wants.
Is it possible? How should I do this?
There are 2 free plugins that allow you to set discount codes based on payment methods:
https://wordpress.org/plugins/woocommerce-auto-added-coupons/ - With over 5K+ active installs, this one seems to be the right choice.
https://wordpress.org/plugins/woocommerce-payment-discounts/ - Although this one has 3K+ active installs, it is specifically meant to give discounts based on payment methods. So this does exactly what you are looking for.
Try out both plugins, preferrably 2nd one first.

WooCommerce add delivery date as hidden product in checkout (Third party payment gateway)

Im developing an e-commerce site with wordpress and woocommerce 2.1. Im using a third party payment gateway (Klarna Checkout) which doesn't offer the customer to specify a delivery date/time. I need to make this feature available but the problem is that the gateway only sends the order-meta from their form, which doesn't offer a date field, when the order is completed. In other words, the standard checkout fields in woocommerce won't be passed to the final order.
My idea of solution is to add a hidden free product called Time, with variations for different time spans, on the checkout page and automatically add this product(with selected variation) to the cart when a customer selects a variation. The specified time would then show as a ordered product when viewing the order in wordpress. How could i do this?
If anyone has a better idea of how to solve this problem feel free to contribute :)
Thanks!
Try this free plugin that adds a delivery date on the checkout page: http://wordpress.org/plugins/order-delivery-date-for-woocommerce/

WooCommerce - Shipping plugin ignored

I've written a plugin that adds a custom shipping method to WooCoomerce.
It seems to be intermittently NOT returning shipping prices.
On the cart page, the shipping estimator works fine; then, when you click through to checkout, it will INITIALLY display all the results (from cheapest to fastest) but on refresh, with correct GUEST billing address, it returns nothing; debugging shows that it does not even call the plugins' shipping calculator or 'enabled' function check. It just says that there are no shipping options for Australia (if this is the only shipping option activated)
Have tried contacting the Woo guys, but nada.
EDIT:
Lessons learned.
Firstly, the big one: WooCommerce uses transients - it caches your shipping results. You can reset these in WooCoomerce settings, system status->tools Extra edit: Lastest WooCommerce version lets you turn this off! .. But only if you are shopping as administrator ..
Secondly: Once the above was out of the way, it simply turned out that I was reading in the posted address details incorrectly, and my plugin was returning 'false' and knocking itself out of the running. Big thanks to xDebug and PHP Storm ..
Thirdly: As an aside, I have also hooked the plugin's instantiation to the woocommerce_shipping_init, as Woo NOW recommends. Check out their revised docs at the shipping method API page
You should at least show us your code :-)
I bet there is something related to shipping address that is removing the shipping options.
If the initial page loads fine, but when address info is updated it doesn't respond correctly it may be a javascript issue. I'm working on a custom shipping plugin right now myself, and when any shipping details are changed it fires an event that updates the shipping results through AJAX. Posting a link to the checkout page, or looking for javascript errors on the front end might be very helpful.

Resources