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

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'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 ...


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

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


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

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

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

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

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

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){ ...


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

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

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

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 formula works: order.lineItems|filter(v => (v.sku == 'BBB' and v.qty >= 3) ) You were missing the v. in front of qty. Look in the next version of commerce ...


2

I set config variable to general config instead of commerce config. That's all..


2

I'm going to lay out the answer here, in case someone else runs into someone else's issue. We are using Postmark to process emails. All of the failures in the queue are email addresses that have previously hard bounced in postmark. The reason it's always the shipping confirmation email has nothing to do with the shipping confirmation email, but the fact that ...


1

It sounds like you have either an order issue or a queue issue. What happens if you try to send that specific email from the order's edit screen? If it's a Twig/order email / syntax problem, you'll get an error. It sounds like you may have already tried this but when you preview an email from Commerce -> Store Settings -> Emails, you're previewing a ...


1

In the case of relational fields, on the title of the related Assets/Categories/Entries is searchable. As stated in the documentation: For Matrix fields, the top-level Use this field’s values as search keywords setting determines whether any sub-fields will factor into results for the parent. For relational fields like Assets, Categories, and Entries, the ...


1

After some further trial and error I have made this work like so. However, it feels like there is or should be a simpler method....what am I missing or what is a better approach? {% set selectedVehicle = craft.entries .section('vehicles') .id(vehicle) .with( [ 'vehicleBrand', 'oemFixings', 'afterMarketFixings' ]) .one() %} {% set ...


1

Would removing required via JS be an option?


1

I like this solution: {# run queue #} {% do craft.app.queue.handleResponse %} {{ craft.app.response.content|raw }} Detailed in this post.


1

If you want to modify the error message, the way to do is not to use the craft.app.session.getFlash('error') value but use the cart.errors instead. Each of the errors has a unique key for specific error then you can add a condition on what message to display. It would something this. {% if cart.errors|length %} <ul> {% for ...


1

The CSRF token is likely expiring. Since pages are cached with Blitz, you must use some strategy to ensure that a fresh CSRF token is loaded into the page on each page that is statically served. The simplest way to do this is to use the Dynamic Content feature in Blitz, specifically craft.blitz.csrfInput(). <form method="post"> {{ craft....


1

After enabling the headless mode in Craft I'm getting the same error in JSON format: Anyway I guess I have to write some module for that extra functionality. Thank you for the tips!


1

UPD 2: Spending more hours gave me the solution: It seems like Ajax generates a new sessionId with each call, so it's impossible to preserve cart along with session Id in that case. As workaround I was trying to pass session id cookie manually, but it was rejected by Axios. What I have found is that you can actually call action=commerce/cart/get-cart&...


1

UPD: after some hours of research I found the solution in this topic: CORS preflight check failing for AJAX login form on different domain Also I had to pass the orderNumber parameter with the value of cart number in payload. However I have a different issue now. First I call ?action=commerce/cart/load-cart&note=from+ajax&number={number} to load my ...


1

Managed to solve this. First, I've added a categories field to the order form. On the checkout page I loop over all lineItems in the cart and collect the category id's like this. {% set categoryIds = [] %} {% for item in cart.lineItems %} {% set categories = item.purchasable.product.productGroup.leaves().all()%} {% for category in categories %} {% ...


1

Yeh there's few workarounds. Your entries field is close to what Nathanial from P&T mentioned on the issue tracker: If you create a global set and add a custom product field. Then select all the products. This gives you the ability to drag and drop the order of the products. You can use this in conjunction with the on save event and catch the save of ...


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