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 ...
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); // ...
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 ...
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 %}
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(...
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....
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 ...
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 ...
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 }}
...
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\...
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 ...
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 > ...
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.
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 = ...
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 ...
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 ...
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 ...
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' %}
{{"...
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 ...
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)
{
....
<...
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.
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/...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
discounts × 21plugin-craftcommerce × 19
templating × 2
plugin-craftcommerce3 × 2
craft3 × 1
plugin-craftcommerce2 × 1
query × 1
ecommerce × 1
debugging × 1
payment-methods × 1
tax × 1
promotions × 1
rounding × 1
commerce4 × 1