6
votes
Accepted
Commerce: what is the purpose of a line item's snapshot?
The snapshot is there so that the key details of an order are forever more available on the order record.
Imagine living with Commerce for a long time - you will of course most likely add, change and/...
- 7,557
4
votes
Accepted
Partially pay for an order
This is certainly still possible with Commerce 3 and Craft 3.
In a custom plugin or module you can listen for the Transactions::EVENT_AFTER_CREATE_TRANSACTION event and amend the transaction amount at ...
- 3,298
3
votes
Accepted
Craft Commerce 3 Decrease line Item qty by one?
Try just POSTing the new absolute quantity you want to change to - e.g. if you have 5 in your cart and want to decrement by one, you'd POST something along these lines:
{
"redirect": &...
- 7,557
3
votes
How to create a faceted search/facet filter in Craft Commerce
Answer edited 2022: I've now written a blog post tutorial on how to do multi-faceted search filtering natively: https://cld.agency/blog/multi-faceted-filtering-in-craftcms
I've done this a few times ...
- 4,564
3
votes
Accepted
Commerce: How to update an order status via the frontend
A customer can not update the order status from the front end. Only a user in the CP with the right permissions can do so from the Edit Order page.
To add this functionality you would need to make ...
- 6,757
3
votes
Accepted
How does one get an order confirmation email to fire immediately in Commerce 3?
There are a couple of options here.
Number 1
If you have the config setting runQueueAutomatically set to false you could call the controller action queue/run via ajax from your success page. This ...
- 830
3
votes
Accepted
Is there a way to get a variants stock quantity in commerce?
You can do the following:
{{ variant.stock }}
- 6,757
3
votes
In Craft Commerce, is it possible to make the product variant weight a required field?
Yes you can, using the Model::EVENT_DEFINE_RULES Put this in your customer module or plugin.
use craft\commerce\elements\Variant;
use craft\base\Model;
use craft\events\...
- 91
3
votes
Accepted
Do "update cart" and "complete cart" as one action
There's a few moving parts here but Commerce 3.3, which was recently released, just introduced support for partial or deferred payments which should help get this done easily.
I'm not sure what your ...
- 6,562
3
votes
Accepted
Craft Commerce: Multiple redirect submit buttons from cart form (checkout/update cart) without ajax
You may be able to use the browser-native <button type="submit"> feature!
Check this out:
<form method="POST">
{{ csrfInput() }}
{{ actionInput('commerce/carts/...
- 3,109
3
votes
Accepted
Add custom field value to Commerce Order Confirmation E-Mail
There are two ways of doing this: you can hook into the "live" product data using {{ item.purchasable.product.articleNumber }} -- and this is probably fine for the use-case of a confirmation ...
- 4,564
2
votes
Accepted
Cannot delete user that was subscribed to a subscription
This is a known bug: https://github.com/craftcms/commerce/issues/1048
And some more characters for Stack Overflow's benefit.
- 4,564
2
votes
Accepted
Commerce 3 upgrade question
Commerce 3 is not a major change from Commerce 2 - you can see what you need to do to update here:
https://docs.craftcms.com/commerce/v3/upgrading.html
Stripe works with Commerce 3 without any ...
- 6,757
2
votes
Server-side address validation in Craft Commerce 3
According to Luke, this is the preferred method for Commerce 3.
In a custom module or plugin:
Event::on(\craft\commerce\models\Address::class, \craft\base\Model::EVENT_DEFINE_RULES, static function(\...
- 166
2
votes
How does one get an order confirmation email to fire immediately in Commerce 3?
I like this solution:
{# run queue #}
{% do craft.app.queue.handleResponse %}
{{ craft.app.response.content|raw }}
Detailed in this post.
- 565
2
votes
Is there a guide for using Craft Commerce headless?
After looking at the Commerce docs further, I see I can use the GraphQL API to get information from Commerce. That is, at least for products. Craft 3.5 will allow GraphQL mutations so perhaps that’ll ...
- 41
2
votes
Accepted
Commerce custom field output
Your customColor3a and customColor3b variables will always be defined so you need to check if empty.
{% if item.options.customColor3a is defined and item.options.customColor3a is not empty %} |
...
- 7,340
2
votes
Accepted
Discount for subscription plans?
"Not yet" is the short answer. https://github.com/craftcms/commerce/issues/295
- 4,564
2
votes
Is it possible to provide an option to pick up an order from the physical store in Craft Commerce?
You could make 'pickup from store' a shipping method.
Then in your checkout form, if a visitor chooses that shipping method, make sure you don't show the shipping address form, and add a hidden ...
- 6,318
2
votes
Generate PDF Receipt in Craft commerece causes error in dompdf
This is a known issue with dompdf on php 7.4: https://github.com/dompdf/dompdf/issues/2003
You can either downgrade your php version to 7.3 or install dompdf/dompdf 0.8.4.
2
votes
Accepted
Accessing Commerce ‘Product Fields’ in events hooks
I believe you're looking for something like:
$purchasable->product->yourEntriesFieldHandle->one()->title
- 4,564
2
votes
Commerce: are Shipping prices always assumed to include tax?
We fixed this by doing three things...
On our tax rate, setting "Taxable Subject" to "Order total taxable price (Line item subtotal + Total discounts + Total shipping)"
Also on ...
- 825
2
votes
Accepted
Craft Commerce — Update order status from frontend?
This feels a bit dirty, but you can actually do this directly in a Twig template like this:
{% set order = craft.orders.id(123).one() %}
{% do order.setAttributes({orderStatusId: 4}, false) %}
{% do ...
- 4,564
2
votes
Accepted
Craft Commerce Product Options that increase price, but do NOT affect stock
Worked it out!
Putting this in a custom module should do the trick..., obviously changing the price modifier and option name to your needs.
Event::on(
LineItems::class,
...
- 575
2
votes
Accepted
Tax validation in Craft Commerce
Probably best to just update the address business tax ID if it is in the wrong format automatically for them.
Event::on(Order::class, Order::EVENT_BEFORE_SAVE, function(\craft\events\ModelEvent $event)...
- 6,757
2
votes
How to create a faceted search/facet filter in Craft Commerce
Algolia is excellent, and I've found the scout plugin to be solid. Algolia will give you pre-built faceted navigation with instantsearch.js so there is very little development time.
Elastic search ...
- 2,492
2
votes
Accepted
Enable single line item mode on Commerce Pro
There is no existing config option for this behaviour with Commerce Pro.
You'd need to write a relatively simple custom module to do this.
You'd probably listen to something like this event:
https://...
- 7,557
2
votes
Accepted
Searching for a way to add products to cart and sending the csrf token with ajax
So normally in your main layout twig template, you'd have something like this to set some JS variables to hold the current CSRF token:
{# Super preliminary JS Stuff #}
<script type="...
- 7,557
2
votes
Custom shipping cost
Yes this is definitely possible.
We don't use any of Commerce's in-built shipping stuff - fields or calculation, as it's too limited for our needs (not Commerce's fault - we have very complicated ...
- 7,557
2
votes
Get a list of countries available for shipping with Ajax in Craft Commerce
You need to provide a CSRF token, alternatively turn it off in your config/general.php file.
Set a token in your twig template:
{% set csrfToken = {
csrfTokenName: craft.app.config.general....
- 440
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
plugin-craftcommerce3 × 80plugin-craftcommerce × 27
craft3 × 25
ecommerce × 8
emails × 4
payment × 4
plugin-development × 3
ajax × 3
modules × 3
order × 3
shipping × 3
stripe × 3
templating × 2
php × 2
error-message × 2
plugin-craftcommerce2 × 2
validation × 2
csrf × 2
status × 2
filtering × 2
adjusters × 2
discounts × 2
payment-methods × 2
vue × 2
plugin-commerce-stripe × 2