WooCommerce - A way of clearing the applied coupons from the current session - woocommerce

When a customer completes an order, I need a way of removing the applied coupons so that when they checkout again, the same coupons aren't applied.
I can't set the coupon to be one use only so I need a method to remove the applied coupons programatically.

Related

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

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

How to apply a coupon to an existing woocommerce subscription

I'm looking for a way to apply coupons to existing woocommerce subscriptions. I create coupons and then under usage restrictions I set the allowed emails to the be the email of a certain user/subscriber.
I would like these coupons to be automatically applied to the users subscription. I want the discount to be visible on the users subscription page. That way it's clear for the user how much the subscription will be discounted on the next renewal.
Is there an easy way to achieve this?
I was hoping I could something with the wcs_get_users_subscriptions filter and then add a function which applies coupons to existing coupons from there?

How to apply discount based on checkout page form fill up

I have developed an eCommerce site based on a Wocommerce theme. I have only one product. I am trying to apply a 10% discount if anyone just fills up/answers some certain form fields of questions in the checkout page. I need to grab those important answer hence offering a 10% discount.
Now my question is how can I achieve the checkout page form customization and apply discount conditionally on the checkout page.
the simplest way that come in my mind is this:
create a one time use per user coupon code
ask the user to fill the form
after the form is submitted print the coupon code
Extra:
If you want you can have an exclusive coupon for every single user, to do this create a coupon programmatically and limit the use (only one time)
https://docs.woocommerce.com/document/create-a-coupon-programatically/#
Is it possibile to grow in complexity by programmatically apply coupon in cart, here a little example that need to be customized to fit your needs:
https://businessbloomer.com/woocommerce-apply-coupon-programmatically-product-cart/
I am not 100% sure but you can do it like this:
1 - Write a PHP function and add filter for it with woocommerce_after_checkout_billing_form hook
2 - Add the questions to the checkout form with relevant input fields
3 - Assign unique id and onchange attributes to those input fields
4 - Write a JS function inside the PHP function to check if those fields are filled before submission (onchange functions)
5 - If yes, return the total value with 10% discount using woocommerce_calculate_totals hook and a simple PHP function for 10% discount
I hope it works, if you need more help I can try these after several hours and post the results.

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.

How to remove a product from WooCoomerce

On our site we are using WooCommerce and the Subscription extension and this is working fine. However, we have recently decided that we are going to remove our subscription service. But what I am concerned about is how to properly remove the subscription setup.
I have manually gone thru and cancelled any active subscriptions so they will no longer be billed. And on a future date (to make sure people have access till the end of their current billing cycle) we plan to completely remove subscriptions.
Would removing the subscriptions extension plugin cause problems? What would be the best method of removing the subscription products (currently I have set the subscription item to out of stock and also set it to private so no more orders can be placed). If I delete the subscription product completely would that affect the sales reports (I am guessing it would as the product would no longer exists).
Also how would deleting a product affect orders where that product was purchased? Would the order just simply show no items (but keep the totals)?
Thanks in advance!
I would delete every subscription product, just go to your woocommerce products and filter by the category you set your subscriptions too and delete them all.
Then on the day which your last sub expires remove the plugin in the normal method.
If you have them as out of stock and private/hidden, that should be good enough until all the subs are finished. I wouldn't remove them as products until at least the last orders are created. If you do, they may not generate.

Resources