Questions tagged [coupon]

For questions related to performing discounts on eCommerce transactions. (Please do not use this tag for questions regarding financial calculations regarding bond coupons and interest rates.)

This tag refers to performing discounts on eCommerce transactions (i.e. taking coupons in the applications OpenCart, Magneto, or WooCommerce applications.) Besides the logic to implement the discounts, this tag could also refer to generation of unique or batch coupon codes.

For financial calculations regarding bond coupons and interest rates, please use a different suitable tag, such as:

499 questions
3
votes
1 answer

Generating code series and taking previous ones into account

I have an SQL database of unique codes (consiting of numbers/letters). I want to generate large amount of new codes for this database, that also need to take into account the previous codes that were not generated with any kind of seed or…
JuhaKangas
  • 875
  • 5
  • 17
3
votes
3 answers

Magento get coupon description

I am trying to retrive the text set in the Magento Coupon Description field to use as part of a validation rule. Does anyone know how to load a coupon price rule using the coupon code and retrieve the associated coupon description text?
paj
  • 1,177
  • 16
  • 33
3
votes
1 answer

Creating a single random Magento coupon

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…
Kale
  • 601
  • 1
  • 8
  • 25
3
votes
1 answer

Magento coupon entities in database

I'm trying to develop a Magento plugin which involves using coupons. Apparently after looking around I found a source that mentions use of a 'salesrule' table for coupons. However when I looked at my database i couldn't find it. However I did find 3…
koramaiku
  • 358
  • 2
  • 5
  • 22
2
votes
1 answer

Get a list of available WooCommerce coupons in a select field

As part of a plugin I am creating with the WooCommerce API, I need to get the coupons to show in the select field. Here is the relevant piece of code: // Get coupons function coupon_list() { $coupon_posts = get_posts( array( …
User_FTW
  • 504
  • 1
  • 16
  • 44
2
votes
1 answer

Prevent WooCommerce coupon stacking on cart and checkout page

I need to prevent two specific coupons from being used together. I successfully implemented this code, which prevents stacking these coupons on the cart page: add_action( 'woocommerce_before_cart', 'check_coupon_stack' ); function…
supernaut
  • 311
  • 3
  • 11
2
votes
1 answer

Add free product when a certain coupon is applied in WooCommerce

I can add a product to cart, when a certain coupon is used via the woocommerce_applied_coupon hook and the add_to_cart() function add_action('woocommerce_applied_coupon', 'apply_product_on_coupon'); function apply_product_on_coupon( ) { global…
AdrianV
  • 109
  • 7
2
votes
1 answer

Generate WooCommerce coupon when comment review is approved

I'm trying to generate a coupon code for customer once his review comment in woocommerce product is approved. I have the whole code ready but once comment is approved nothing happen. My code only works with comment_post hook but not with the…
Lubo Masura
  • 1,034
  • 6
  • 20
2
votes
2 answers

Split discount (coupon) row into multiple deducted cost rows in WooCommerce order totals table

If there are 2 discount coupons used, it shows the sum of 2 coupons in the Woocommerce order totals table, while I want to show the deducted cost of each coupon separately. For example, 2 coupons are inserted, currently it shows: coupon : $100 I…
social.reza
  • 314
  • 3
  • 11
2
votes
1 answer

Restrict use of coupon if customer have used related coupons in previous orders in WooCommerce

I am looking for a way, to limit coupon usage and to display an error message if a customer have used related coupons in previous orders before in WooCommerce. By related coupons, I mean: couponcodes that appear in a predefined array along with the…
Jod
  • 87
  • 5
2
votes
1 answer

Add Applied Coupon Description to WooCommerce Admin Email notifications

Trying to put the description of applied coupon into the "New Order" admin email with not success So far trying to use this code I put into functions.php add_action( 'woocommerce_email_order_details', 'display_applied_coupons', 10, 4 ); function…
2
votes
1 answer

Create a coupon programmatically since WooCommerce 3+

I add coupons at woocommerce with this code programmatically. if(empty($coupon_post)){ $coupon = array( 'post_title' => $coupon_code, 'post_content' => '', 'post_status' => 'publish', …
2
votes
1 answer

WooCommerce specific coupon discount based on product category

I've a problem with this code to apply different percentage of discount to product in different category The function work but is execute n times where n depends on the number of products in cart add_filter( 'woocommerce_coupon_get_discount_amount',…
2
votes
1 answer

Get used coupon codes and related discount amounts from WooCommerce orders

I need to insert in a custom plugin the code to get the name of the discount codes I enter in the settings, the discount obtained with the code and the total. Based on Get coupon data from WooCommerce orders answer code, I have inserted the…
2
votes
1 answer

Woocommerce: Mandatory coupon for specific products

Based on Make coupon field mandatory for a product category in WooCommerce answer, I am trying to implement a mandatory coupons for specific products in woocommerce. Here is my code attempt: add_action( 'woocommerce_check_cart_items',…