6

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/or remove products (or variations) as time goes by. You might simply disable ones you remove, or you might delete them. If Commerce did not have line item ...


4

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 this point in the process. For example, you could make your own payment form that includes a partPaymentAmount field and posts to the normal commerce/payments/...


3

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 your own controller action endpoint (in a plugin or module) that does the following: <?php namespace modules\mymodule\controllers; use modules\mymodule\...


3

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": "6bb2a73aac3479c68e0946e4455624e2c1b840bc2b6356074a51ba01ee1234d/cart", "action": "commerce/cart/update-cart", "...


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 would trigger the queue to run. Number 2 You can use the EVENT_AFTER_COMPLETE_ORDER event to run some custom code, in a module or plugin. In that code you can ...


3

You can do the following: {{ variant.stock }}


3

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\DefineRulesEvent; Event::on( Variant::class, Model::EVENT_DEFINE_RULES, function(DefineRulesEvent $event) { ...


3

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 checkout looks like but one way to handle it would be to post via ajax. Basically anything that updates on-the-fly (addresses, line items, etc.) needs to to get ...


2

This is a known bug: https://github.com/craftcms/commerce/issues/1048 And some more characters for Stack Overflow's benefit.


2

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 update needed: https://github.com/craftcms/commerce-stripe/blob/develop/composer.json#L28


2

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(\craft\events\DefineRulesEvent $event) { $rules = $event->rules; $rules[] = [['firstName','lastName'], 'required']; $event->rules = $rules; });...


2

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 encompass some sort of write API to commerce. If not, I’ll have to create custom endpoints in the Craft app to do the following: Create customer account Edit ...


2

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 %} | Custom Color 1: {{ item.options.customColor3a }} {% endif %} {% if item.options.customColor3b is defined and item.options.customColor3b is not empty%} | ...


2

"Not yet" is the short answer. https://github.com/craftcms/commerce/issues/295


2

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 input to set order.shippingSameAsBilling to true. Commerce will then populate the shipping address with the billing address details. Code is untested, but it should ...


2

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

I believe you're looking for something like: $purchasable->product->yourEntriesFieldHandle->one()->title


2

I've done this a couple of times in Twig and a couple of times with the Faceted Nav plugin and would recommend doing it yourself in Twig, as it gives you full control. More specifically, Faceted Nav plugin cannot achieve what most people want which is to separate the filter groups with 'AND' logic while separating the individual filters in each group with '...


2

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 comes with the added complexity of running/configuring an ES server, will likely require on-going maintenance. However if you have the time and don't want to ...


2

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, LineItems::EVENT_POPULATE_LINE_ITEM, function(LineItemEvent $event) { // @var LineItem $lineItem $lineItem = $event-...


2

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) { /** @var Order $order */ $order = $event->sender; if ($order->getShippingAddress() && $order->getShippingAddress()->...


2

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://craftcms.com/docs/commerce/3.x/events.html#beforeaddlineitemtoorder ...and remove anything else in the cart before the new item is added. or, thinking about it, ...


2

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="text/javascript"> window.csrfTokenName = "{{ craft.app.config.general.csrfTokenName|e('js') }}"; window.csrfTokenValue = "{{...


2

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 shipping requirements!). You will want to write yourself a custom module with either a full custom shipping calculator, or an adjuster for shipping. You'd use an ...


2

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.csrfTokenName, csrfTokenValue: craft.app.request.csrfToken, } %} <script type="text/javascript"> window.Craft = {{ csrfToken|json_encode|raw }}...


2

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 "Content-Type: application/json"%} {{ craft.commerce.countries.getAllCountries() | json_encode() | raw }} Which would give you an endpoint you can ...


2

Update: it looks like it was an issue with the secure cert on the site.  Once we got that updated, purchases are going through as normal.


2

You can remove a line item by including a remove parameter in the request. This example adds a checkbox the customer can use to remove the line item from the cart: {% set cart = craft.commerce.carts.cart %} <form method="post"> {{ csrfInput() }} {{ actionInput('commerce/cart/update-cart') }} {% for item in cart.lineItems %} ...


2

I think I figured out the problem. This was my first time switching to the project.yaml configuration Deleting and rebuilding the project config allowed me to change the Commerce > System Settings > Email > Language which fixed the error.


2

Remembering a) that not all customers are users and b) that a user can be in one, or more, groups.....then something like this can be used to check if a user is in a particular group: $order = $lineItem->getOrder(); $user = Craft::$app->users->getUserByUsernameOrEmail($order->email); if ($user){ ...


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