coupon

Apply automatically a coupon based on specific cart items count in Woocommerce

那年仲夏 提交于 2019-11-29 17:13:16
I am trying to automatically trigger a coupon to be applied in the cart specifically for when there are 4 items in the cart. The coupon is pre-created in the Woocommerce back-end of the site "tasterbox" I am using an amended version from this answer code: Add WooCommerce coupon code automatically based on product categories Here is my code version: add_action( 'woocommerce_before_calculate_totals', 'wc_auto_add_coupons', 10, 1 ); function wc_auto_add_coupons( $cart_object ) { // Coupon code $coupon = 'tasterbox'; if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return; // Initialising variables

Apply automatically a coupon based on specific cart items count in Woocommerce

扶醉桌前 提交于 2019-11-28 11:36:45
问题 I am trying to automatically trigger a coupon to be applied in the cart specifically for when there are 4 items in the cart. The coupon is pre-created in the Woocommerce back-end of the site "tasterbox" I am using an amended version from this answer code: Add WooCommerce coupon code automatically based on product categories Here is my code version: add_action( 'woocommerce_before_calculate_totals', 'wc_auto_add_coupons', 10, 1 ); function wc_auto_add_coupons( $cart_object ) { // Coupon code

GET a coupon code via URL and apply it in WooCommerce Checkout page [closed]

痞子三分冷 提交于 2019-11-28 10:21:31
I have a WooCommerce website and when customer add-to-cart a product, it is get redirected to checkout page, so cart page is not accessible. I would like to apply coupon via URL ( GET ) on checkout page, with something like https://example.com/?coupon_code=highfive . When customer click this URL then the coupon code is stored in browser sessions. Then if he add-to-cart any product then the coupon is applied into checkout page. Is this possible? Update 3: This can be done in a very simple way with the following 2 hooked functions: The first one will catch the coupon code in the Url and will set

Apply a coupon programmatically in Woocommerce

拈花ヽ惹草 提交于 2019-11-27 18:32:37
In Woocommerce I'm trying to find a way to apply a 10% discount to an entire customer's order if the weight in the cart is over 100 lbs. I'm part way to achieving this. For the next step, I'm looking for a way to programmatically apply a coupon code via action/hook through functions.php. It appears that I can use the function woocommerce_ajax_apply_coupon to do this ( http://docs.woothemes.com/wc-apidocs/function-woocommerce_ajax_apply_coupon.html ) but I am unsure of how to use it. So far I've modified cart.php to get the total weight of all the products in the cart, i've created a coupon

Coupon code generation

最后都变了- 提交于 2019-11-27 09:06:22
问题 I would like to generate coupon codes , e.g. AYB4ZZ2 . However, I would also like to be able to mark the used coupons and limit their global number, let's say N . The naive approach would be something like "generate N unique alphanumeric codes, put them into database and perform a db search on every coupon operation." However, as far as I realize, we can also attempt to find a function MakeCoupon(n) , which converts the given number into a coupon-like string with predefined length. As far as

How to retrieve a list of WooCommerce orders which use a particular coupon?

你。 提交于 2019-11-27 06:26:24
问题 I'm trying to write a function that retrieves a list of WooCommerce orders which use a specified coupon code and are in a specified date range, then sums the total discounts applied to those orders. After a little googling I feel like I should be using something like $customer_orders = get_posts( array( 'numberposts' => -1, 'meta_key' => ???, 'meta_value' => $CouponToSearchFor, 'post_type' => wc_get_order_types(), 'post_status' => array_keys( wc_get_order_statuses() ), ) ); I've tried: 'meta

GET a coupon code via URL and apply it in WooCommerce Checkout page [closed]

北慕城南 提交于 2019-11-27 02:53:32
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last year . I have a WooCommerce website and when customer add-to-cart a product, it is get redirected to checkout page, so cart page is not accessible. I would like to apply coupon via URL ( GET ) on checkout page, with something like https://example.com/?coupon_code=highfive . When customer

Apply a coupon programmatically in Woocommerce

空扰寡人 提交于 2019-11-26 19:29:21
问题 In Woocommerce I'm trying to find a way to apply a 10% discount to an entire customer's order if the weight in the cart is over 100 lbs. I'm part way to achieving this. For the next step, I'm looking for a way to programmatically apply a coupon code via action/hook through functions.php. It appears that I can use the function woocommerce_ajax_apply_coupon to do this ( http://docs.woothemes.com/wc-apidocs/function-woocommerce_ajax_apply_coupon.html ) but I am unsure of how to use it. So far I