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/...
user avatar
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 ...
user avatar
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": &...
user avatar
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 ...
user avatar
  • 6,682
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 ...
user avatar
3 votes
Accepted

Is there a way to get a variants stock quantity in commerce?

You can do the following: {{ variant.stock }}
user avatar
  • 6,682
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\...
user avatar
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 ...
user avatar
  • 6,467
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/...
user avatar
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 ...
user avatar
  • 3,924
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.
user avatar
  • 3,924
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 ...
user avatar
  • 6,682
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(\...
user avatar
  • 146
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.
user avatar
  • 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 ...
user avatar
  • 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 %} | ...
user avatar
  • 7,160
2 votes
Accepted

Discount for subscription plans?

"Not yet" is the short answer. https://github.com/craftcms/commerce/issues/295
user avatar
  • 3,924
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 ...
user avatar
  • 6,288
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.
user avatar
2 votes
Accepted

Accessing Commerce ‘Product Fields’ in events hooks

I believe you're looking for something like: $purchasable->product->yourEntriesFieldHandle->one()->title
user avatar
  • 3,924
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 ...
user avatar
  • 3,924
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, ...
user avatar
  • 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)...
user avatar
  • 6,682
2 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 ...
user avatar
  • 3,924
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 ...
user avatar
  • 2,437
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://...
user avatar
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="...
user avatar
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 ...
user avatar
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....
user avatar
  • 440
2 votes

Get a list of countries available for shipping with Ajax in Craft Commerce

The controller action you are hitting returns a template and I think that it is why you are getting this error. If you don't have headlessMode on (docs) you could make a quick template, add: {% header ...
user avatar
  • 7,160

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