Hot answers tagged

3

There is a way to do this, obviously, it is worth noting that the code below is written to be easy to understand and could be improved. Also, it is worth noting that there are plenty of things to think about when implementing something like this. Take careful consideration about how this will affect all parts of the e-commerce experience, whether that is ...


3

The onBeforeSaveOrder event runs before all of the adjustments are calculated (including taxes), so it seems like that's what you're looking for.


2

Commerce 2 {% set allTaxRates = craft.commerce.taxRates.allTaxRates() %} {% for taxRate in allTaxRates %} {{ taxRate.name }}<br> {% endfor %} taxRate will be an instance of craft\commerce\models\TaxRate Commerce 1 If you're looking to get all of the tax rates setup in Commerce from a template, something like this should work: {% set ...


2

How far does Craft Commerce go when a user puts an order? When an order is paid in full it is marked as complete and gets a default order status that you can configure, after that a store admin would move the order to another status. An order can also be completed if the payment gateway 'authorizes' the full amount of the order, allowing a store admin to '...


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

@nfourtythree's answer was correct, but just for a 2nd example, here's what I ended up going with: use craft\commerce\Plugin; use craft\commerce\elements\Order; use craft\commerce\models\OrderAdjustment; use craft\events\ModelEvent; use yii\base\Event; Event::on( Order::class, Order::EVENT_AFTER_SAVE, function(ModelEvent $event) { /* @...


1

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

As of Commerce 2.0, there is no support for multi-site apart from a product’s custom field information. A cart exists in the session, once per Craft installation, and there are not separate carts per site. Multi-site is something we plan to add in the future. Having said that, a cart stores the current orderLanguage based on the current language of the ...


1

The current rule for the total in Commerce 1 is in craft/plugins/commerce/models/Commerce_ShippingRuleModel.php starting at line 214: if ($this->minTotal && $this->minTotal > $order->itemTotal) { return false; } if ($this->maxTotal && $this->maxTotal <= $order->itemTotal) { return false; } Try changing it to ...


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