Skip to main content
5 votes
Accepted

How to represent member discount for Commerce products?

Options #1 and #3 are the two options you'll want to decide between, and you've hit the nail on the head in terms of the pros and cons of each. If a discount code being deleted / modified poses a ...
cherrykoda's user avatar
  • 1,114
3 votes
Accepted

how to round Discounts (either half of full number) or total of cart

Are you using a custom adjuster for the discount? If yes, then just use round() to round up. ... $num = $adjustment->amount; // 12.48 $adjustment->amount = round($num, 1, PHP_ROUND_HALF_UP); // ...
RomanAvr's user avatar
  • 712
3 votes
Accepted

Discount Code applies to cart successfully but doesn't do anything. Am I missing something?

The reason for the discount not being applied is that nearly all your products have not been marked as promotable (by looking at your database): Screenshot: http://jmp.sh/3FAK6NH No sales or ...
Luke Holder's user avatar
  • 6,897
2 votes

Check if there is a discount and, is yes, how much

Something like this? {% if item.discount %} <tr> <td>Your discount is {{ item.discount|commerceCurrency( currency ) }}</td> </tr> {% endif %}
Seth Warburton's user avatar
2 votes
Accepted

List applied discounts that have codes

(There can be only one code on a cart at any one time) Here's some example code that does the sort of thing you want: {% if cart.couponCode %} {% set coupon = craft.commerce.getDiscountByCode(...
Jeremy Daalder's user avatar
2 votes

View all discounts applied to a cart and remove discounts from cart

You've sort of answered your own question - Commerce only allows one coupon on a cart at any time (currently). To determine if a coupon is set, and print the code, it's basically: {% if cart....
Jeremy Daalder's user avatar
2 votes

Applying coupon codes via URL

The following code can be used in the init method of a custom module. Event::on( View::class, View::EVENT_BEFORE_RENDER_PAGE_TEMPLATE, function($event) { // Check query string for ...
nfourtythree's user avatar
2 votes
Accepted

Commerce: Is there any way to give a discount for Product A if the costumer buy 3 Product B?

We will need to uncomment this line to allow |filter used in condition formulas: https://github.com/craftcms/commerce/blob/develop/src/services/Formulas.php#L198 If you do that manually yourself this ...
Luke Holder's user avatar
  • 6,897
2 votes
Accepted

Payment Method and Discount elements query by ID in Twig

Commerce 1: {% set paymentMethod = null %} {% for pm in craft.commerce.paymentMethods %} {% if pm.id == 2 %}{% set paymentMethod = pm %}{% endif %} {% endfor %} {{ paymentMethod.name }} ...
Luke Holder's user avatar
  • 6,897
1 vote

Commerce 3: Apply discount only to additional items

You need to add the adjuster to your logic via a module/plugin: And the main body of your adjuster should look like this (if I correctly read your logic): <?php namespace modules\mymodule\...
RomanAvr's user avatar
  • 712
1 vote

Applying several discounts for amount range (> 100$ -> 5%, > 200$ -> 10%)

The Commerce GUI doesn't let you set a whole cart discount but you can do it as an adjuster in a module/plugin. Setup the scaffolding for a module at pluginfactory then add a folder inside called the ...
RitterKnight's user avatar
  • 6,582
1 vote

Applying several discounts for amount range (> 100$ -> 5%, > 200$ -> 10%)

Found the answer: in both discounts "Don’t apply any subsequent discounts to an order if this discount is applied" has to be active. and the discount with the higher value (in my case > ...
Henrik's user avatar
  • 425
1 vote
Accepted

Craft Commerce: discount taxation

Got to bottom of this - is down to how the Tax Rules are set-up. Taxable Subject was set to Line Item but should have been set to Order Total.
Cole Henley's user avatar
  • 1,781
1 vote
Accepted

Commerce 1 find if Discount object is valid based on start/end dates (Twig)

In Commerce 1, craft.commerce.discounts will return an array of Commerce_DiscountModel objects of all available discounts. public function getAllDiscounts($criteria = []) { $records = ...
Brad Bell's user avatar
  • 67.6k
1 vote

Commerce Discount: spend $X, get product free

I don't think avoiding an adjuster or plugin approach here really gains you anything much and it probably creates potential issues - it will likely just make the discount rules confusing as you can't ...
Jeremy Daalder's user avatar
1 vote
Accepted

Show all discounts at checkout with Craft Commerce

Hmm, something else is at play here. I use: {% if cart.totalDiscount != 0 or cart.couponCode %} - {{ cart.totalDiscount | currency(cart.currency) }} ...and it works. Are you sure the promotion ...
Jeremy Daalder's user avatar
1 vote

How to apply a discount on cart weight ?

It would probably be best to make your own shipping adjuster. I have attached an example plugin here: http://jmp.sh/wC95ZPj The adjuster plugin I have linked can look at the weight of the cart, it's ...
Luke Holder's user avatar
  • 6,897
1 vote

Check if there is a discount and, is yes, how much

For some reason the {% if item.discount %} isn't working for me. I've solved it by comparing the item.discount value. If not 0.0000 then it may show up {% if item.discount != '0.0000' %} {{"...
iDzine's user avatar
  • 113
1 vote

Error trapping on discount codes based on Cart contents

So this is for coupons? If a coupon can't be applied during an updateCart, you'll get back the rather unhelpful response in JSON of {"error":"Cart not completely updated."} We intercept this, and ...
Jeremy Daalder's user avatar
1 vote

In Commerce, can I apply a discount only on a specific number of one product?

You can achieve this with a custom adjuster. Please refer the code snippet below. Create a new adjuster and apply your logic here // check each line item foreach($lineItems as $lineItem) { .... <...
Dasun Rathnayake's user avatar
1 vote
Accepted

In Commerce, can I apply a discount only on a specific number of one product?

As far as the release notes from Commerce 1.2: https://craftcommerce.com/changelog#build1323 It can only be given a minimum quantity of items now.
Bram B's user avatar
  • 353
1 vote

Check if cart contains valid products for discount code

I have now updated this code for Craft Commerce 2: {% set codeError = null %} {% set cartProductIds = [] %} {% set discountCodeOK = null %} {# THIS CHECKS THE DISCOUNT CODE FOR IF THERE ARE ANY VALID/...
Terry Upton's user avatar
  • 1,894

Only top scored, non community-wiki answers of a minimum length are eligible