coupon

Allow specific products to be purchase only if a coupon is applied in Woocommerce

寵の児 提交于 2019-12-11 09:59:03
问题 I am working on a woocommerce website and I am trying to restrict a product to be purchased only if a coupon is applied for it, so it should not be processed without adding a coupon code. User must enter a coupon code to be able to order this specific product (not on all other products). Any help is appreciated. 回答1: For defined products, the following code will not allow checkout if a coupon is not applied, displaying an error message: add_action( 'woocommerce_check_cart_items', 'mandatory

How to trash expired and used coupons in Woocommerce automatically?

本秂侑毒 提交于 2019-12-11 08:09:55
问题 In my functions.php I want to add a function that moves expired coupons and/or coupons that have reached their usage limit to the trash. I would like to trash coupons that have a usage limit of 1 and a usage count of 1 or more. I would like this function to run on a daily basis. I have already found a solution for the expired coupons. However I still need the coupons that have reached their usage limit to be removed to the trash as well. The below code is taken from this website. https:/

Auto apply or remove a coupon in Woocommerce cart for a specific product id

▼魔方 西西 提交于 2019-12-11 04:29:23
问题 I am applying automatically a coupon when there is a product id 1362 in the cart, but when someone adds another product and delete the 1362 the coupon stays applied, how to prevent this by removing the coupon if there is no 1362 product id in the cart with Woocommerce ? I know we can restrict coupon to a product but i don't want this, i want my coupon to be applied to all products cart only if there is the product with id 1362 in this cart. add_action( 'woocommerce_before_cart', 'bbloomer

How to add coupon to WooCommerce product page

依然范特西╮ 提交于 2019-12-11 03:15:49
问题 I am using WordPress (4.9.8) with WooCommerce (3.4.5) and I would like to add a coupon field in single product pages. I've been looking at all Woocommerce templates, but I cannot find a way to add the Woocommerce coupon field onto the product page. Any ideas? I don't want to use a plugin for this. 回答1: The following code will add a custom text input field for coupon in single product pages before add to cart button. If a coupon code is inputed in that field when the product will be added to

Exclude product from all coupons in WooCommerce

懵懂的女人 提交于 2019-12-10 12:31:46
问题 I have searched all over the internet, but it doesn't seem to be any answer anywhere in spite of countless people asking the question. Is there any way to exclude a specific product from ALL coupons? I understand that you can do it on coupon level, but this is rather messy especially as a lot of people have automatic coupons, several people creating coupons etc… TLDR: Any way to make a product excluded from all coupons at Product level . 回答1: Here is a nice way to automate this process. 1) We

WooCommerce: Check if coupon is valid

被刻印的时光 ゝ 提交于 2019-12-10 09:34:14
问题 I am trying to check if a coupon is still valid (hasn't reached its usage limit) and display content under this condition. The reason for this is that I want to be able to hand out a coupon code to particular visitors, but obviously don't want to hand out a coupon that has already reached it's usage limit. I am trying to achieve this with PHP and imagine the code to be something like this: <?php if (coupon('mycouponcode') isvalid) { echo "Coupon Valid" } else { echo "Coupon Usage Limit

Creating a single random Magento coupon

断了今生、忘了曾经 提交于 2019-12-09 13:42:25
问题 I'm having some trouble. What I want to do is automatically generate a single random coupon code in Magento each time someone subscribes to our newsletter. The coupon is 10 dollars off anything and will have an exp. date of two weeks after subscription. So, I'm trying to write a simple script that trips when the "subscribe to our newsletter" form is submitted that will talk to Magento, ask Magento for a single random coupon code, set a few basic price rules (10 bucks off anything, one use per

Send an email notification when a specific coupon code is applied in WooCommerce

泄露秘密 提交于 2019-12-08 08:05:47
问题 I'm looking to setup an affiliate program, starting with the email notifications like when someone applies the coupon code of a an affiliate user. For example: Coupon code "Bob" applied by a customer. An email notification is sent to "bob@gmail.com" (an affiliate) about the coupon code "bob" applied by a customer in cart or checkout, before order is submitted . I have tried to use (without any luck) : $order->get_used_coupons() Then once order is completed, an email notification will be sent

WooCommerce Student Discount

时光总嘲笑我的痴心妄想 提交于 2019-12-08 03:30:19
问题 I need to create a coupon in WooCommerce that will only work if the user has an email which ends in .ac.uk . For example student.name@uwl.ac.uk or teacher@kings.ac.uk . The discount would be 10% off the total shopping basket. I can't find any solutions online or any plugins which could help. Any ideas? Thanks. 回答1: You can use this Auto apply Discount Coupon to Customer’s Purchase function with the right conditionals (user email finishing by ac.uk ): add_action('woocommerce_before_cart_table'

List Coupon with order details in WooCommerce

拜拜、爱过 提交于 2019-12-07 20:16:43
问题 I have a site with 1000 coupons. All the coupons have a usage limit of one. Im using the code provided by Raunuk Gupta to export coupons directly from the SQL database. How WooCommerce Coupons are stored in Database ? Is it possible to retrieve order meta of the user that used the coupon? I would like to include in the report the user's name, email address and possibly some other custom fields. Thank you. We generate 1000 coupons and provide it to a company ( client ). Each coupon has a usage