4

To get an adjuster working, it's really all about consistent naming and making sure PHP can find the class. Here are the main things to address: Your adjuster should be defined in a file that matches it's classname So in this case a folder off the main plugin folder: /craft/plugins/businesslogic/Adjusters/BusinessLogic_TaxRemover.php Include the ...


4

The error indicates that you're type-hinting the wrong class. Note this line in the error message: Argument 1 passed to amss\amss\AMSS::amss\amss{closure}() must be an instance of amss\amss\RegisterComponentTypesEvent, instance of craft\events\RegisterComponentTypesEvent given This comes from the type-hint in your function: function(...


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


2

Answer is yes, you could use an adjuster to try and make the price "even" while in the cart.


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

Success! 1) I have an Event that does a EVENT_BEFORE_SAVE_ELEMENT check. Event::on(Elements::class, Elements::EVENT_BEFORE_SAVE_ELEMENT, function(Event $event){ /** * Runs so an admin doesn't have to set SKU or Slug when creating a NEW SONG * This Event will also set the Price based on the Price Group Category Selected */ // Only ...


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) { /* @...


2

Your instinct to try the Adjuster API is spot-on. However, you've missed one critical aspect of how Adjusters work that may help explain why the changes you're making are unstable or invisible. Modifying the price attribute of a LineItem is not a guarantor of any particular behavior. In fact, the price is often just the Variant's base price, memoized—not ...


1

For anyone else viewing this question - until there is a zero value adjuster as mentioned by Luke, my solution has been to simply do the discount checks in my custom module. A little messy but it'll do the job for now.


1

It seems you're setting the adjuster $taxAdjuster->amount to zero. This should be the correct adjuster code... namespace Commerce\Adjusters; use Craft\Commerce_LineItemModel; use Craft\Commerce_OrderAdjustmentModel; use Craft\Commerce_OrderModel; class TaxExempt_TaxAdjuster implements Commerce_AdjusterInterface { public function adjust(...


1

I'm not sure but this jumped out at me $myAdjuster->amount = -$order->totalTax; I don't think you can "negative" a variable in that way. Try $myAdjuster->amount = $order->totalTax * -1; instead


1

Turns out it was another plugin interfering with the order total.


1

carbonBalanceAdjuster.php should be CarbonBalanceAdjuster.php since the name of the class is CarbonBalanceAdjuster and you're probably on a case-sensitive file system, which is why auto-loading can't find it. The same goes for your other plugin files as well. You can use https://pluginfactory.io to generate boilerplate plugin code to help avoid case-...


1

At the moment, both are not possible. The order is locked from recalculation when the order is marked as completed - the final price being locked in. In a future release we will introduce the concept of order editing after order completion. Right now, you could manually insert an adjustment row into the database, along with the changes to the order's order....


1

I've built a plugin which uses it's own events before, I guess the way to do it would be the same for separate plugins, however this is untested for your use case. This should go in your plugin service // Import the event from the other plugin Craft::import('plugins.otherPluginHandle.events.OtherPluginEvent'); /Initialise the plugins event and pass ...


1

I put together an example adjuster that checks for a shipping address in Switzerland or the EU, and then applies the 8% or 19% adjustment to the order's item subtotal. It does not include shipping in the tax amount. You would still need to register this via a plugin, see this thread for an example. <?php namespace Commerce\Adjusters; use ...


1

From your code examples, I believe the issue if you have a file named adjusters/BusinessLogicAdjusters.php, but the class name for that file is BusinessLogic_TaxRemover.


1

I'm finding the question hard to follow, but if I am understanding you, then yes I would do it all in the adjuster - rather than using a discount here... I don't see what using a Commerce discount here offers, as you can't really express your credits system in any way meaningful that relates to a Commerce discount I think. So this indeed looks like a job ...


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