<p>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:</p>

<p><strong>Your adjuster should be defined in a file that matches it's classname</strong></p>

<p>So in this case a folder off the main plugin folder:</p>

<pre><code> /craft/plugins/businesslogic/Adjusters/BusinessLogic_TaxRemover.php
</code></pre>

<p><strong>Include the Adjuster class file.</strong> </p>

<p>You can do this (at least) two ways:</p>

<p><code>include</code> or <code>require</code> the adjuster file in your main plugin class</p>

<p>e.g.</p>

<pre><code>&lt;?php
namespace Craft;

require_once('Adjusters/BusinessLogic_TaxRemover.php');
</code></pre>

<p>OR you can use Craft::import (which is probably the better way I guess?)</p>

<pre><code>Craft::import('plugins.businesslogic.adjusters.BusinessLogic_TaxRemover');
</code></pre>

<p>** The Classname must match the filename **</p>

<p>So e.g. in this case</p>

<pre><code>&lt;?php

namespace Commerce\Adjusters;
use Craft\Commerce_LineItemModel;
use Craft\Commerce_OrderAdjustmentModel;
use Craft\Commerce_OrderModel;

class BusinessLogic_TaxRemover implements Commerce_AdjusterInterface {

   etc
}
</code></pre>

<p><strong>You must also finally register your Adjuster with commerce</strong> </p>

<p>And again you must use the same classname (and be mindful of namespaces!)<br>
So in this example:</p>

<pre><code>public function commerce_registerOrderAdjusters(){
    return [
        new \Commerce\Adjusters\BusinessLogic_TaxRemover

    ];
}
</code></pre>

CC BY-SA 3.0
2017-04-03T13:42:01.340Z
I think I've done that already, within the init() function?
Clive Portman
CC BY-SA 3.0
2017-04-03T13:45:33.347Z
I've also tried `require_once('adjusters/GiftVouchers_Adjusters.php');` after defining the `namespace`. Neither seem to do anything so I think it must be a routing issue.
Clive Portman
CC BY-SA 3.0
2017-04-04T00:04:23.587Z
Yeah looking at it on a bigger screen, Brad is right.  I use e.g.

```
<?php
namespace Craft;

require_once('Adjusters/BusinessLogic_TaxRemover.php');
```
...at the top, that works.  But my file name is Adjusters/BusinessLogic_TaxRemover.php
Jeremy Daalder
CC BY-SA 3.0
2017-04-04T00:04:51.183Z
(the import arrpoach will work too, with the right name)
Jeremy Daalder
CC BY-SA 3.0
2017-04-04T09:11:13.710Z
I don't suppose you have a project on GitHub available that has this working code? I've put mine here if that helps: https://github.com/cliveportman/craftcommerce-adjuster
Clive Portman
CC BY-SA 3.0
2017-04-05T00:51:35.363Z
Ok I have edited my answer above to show all the things you must do to get an adjuster working...if you follow all of that, it will work for sure...I've tested it :)  Not up on github I'm afraid, it's part of a project....but it definitely works
Jeremy Daalder
CC BY-SA 3.0
2017-04-05T08:29:29.930Z
Can I check "So in this case a folder off the main plugin folder:" means a folder within my plugin's folder (e.g. /craft/plugins/businesslogic/Adjusters/) and not a new folder within /craft (e.g. /craft/Adjusters)?
Clive Portman
CC BY-SA 3.0
2017-04-05T08:31:20.120Z
Yep, within the plugin.  What's the exact error you're getting now?
Jeremy Daalder
CC BY-SA 3.0
2017-04-05T09:19:29.350Z
I've updated the question - it's the same error.
Clive Portman
CC BY-SA 3.0
2017-04-05T09:41:28.010Z
hmm, it really looks exactly as I have it working here now....I'll try and give it a go on windows here in a bit..perhaps it's somehow environmental somehow (but I don't really thing so).  Can you maybe slack me an image of your plugins whole folder structure as a check?
Jeremy Daalder
CC BY-SA 3.0
2017-04-05T12:02:39.160Z
Nice one Jeremy. PHP7 strikes again. The docs over at https://craftcommerce.com/docs/adjusters should probably be updated, too.
Clive Portman
CC BY-SA 3.0
2017-04-05T12:03:25.570Z
Yep will let Luke know
Jeremy Daalder
CC BY-SA 3.0
2017-09-12T09:04:00.023Z
It seems like there are some things missing from this thread. What was the PHP7 issue alluded to?
foamcow
CC BY-SA 3.0
2017-04-03T13:33:46.727Z
2017-04-05T11:21:05.677Z
2017-04-05T11:21:05.677Z
Jeremy Daalder
<p>From your code examples, I believe the issue if you have a file named  <code>adjusters/BusinessLogicAdjusters.php</code>, but the class name for that file is <code>BusinessLogic_TaxRemover</code>.</p>

CC BY-SA 3.0
2017-04-04T09:07:13.627Z
I've renamed `adjusters/BusinessLogicAdjusters.php` to `Adjusters/BusinessLogic_TaxRemover.php`, used `require_once('Adjusters/BusinessLogic_TaxRemover.php');` after the namespace in the main plugin file but still no luck. I've edited my question with the updated code.
Clive Portman
CC BY-SA 3.0
2017-04-05T00:40:36.823Z
Brad is still on the money here, it's a naming issue still...in this case you have the wrong classname in `commerce_registerOrderAdjusters()` - you need to change that to `new BusinessLogic_TaxRemover` - I put up an issue on your github
Jeremy Daalder
CC BY-SA 3.0
2017-04-05T00:52:46.620Z
See my updated answer for a more complete answer...
Jeremy Daalder
CC BY-SA 3.0
2017-04-05T08:25:54.750Z
Thanks for you help Jeremy. I've made fixed your issue on Github, correcting the register of the Adjuster, but I get the same error. I think I'd actually tried that previously and had no luck with it. I've updated my question to include the corrected code.
Clive Portman
CC BY-SA 3.0
2017-04-03T18:11:29.857Z
2017-04-03T18:11:29.857Z
Brad Bell
<p>Starting with the Business Logic plugin from <a href="https://github.com/lindseydiloreto/craft-businesslogic" rel="nofollow noreferrer">https://github.com/lindseydiloreto/craft-businesslogic</a> I'm following <a href="https://craftcms.stackexchange.com/questions/14106/3-for-2-etc-with-craft-commerce">3 for 2 etc with Craft Commerce</a> to get started.</p>

<p>I have my main plugin file containing:</p>

<pre><code>&lt;?php
namespace Craft;
require_once('Adjusters/BusinessLogic_TaxRemover.php');

class BusinessLogicPlugin extends BasePlugin
{

    public function getName()
    {
        return 'BusinessLogic';
    }

    public function getDescription()
    {
        return '';
    }

    public function getVersion()
    {
        return '1.0.0';
    }

    public function getDeveloper()
    {
        return craft()-&gt;getSiteName();
    }

    public function getDeveloperUrl()
    {
        return '';
    }

    public function init()
    {
    }

    public function commerce_registerOrderAdjusters(){

        return [

            new Commerce_TaxAdjuster

        ];
    }

}
</code></pre>

<p>And within <code>Adjusters/BusinessLogic_TaxRemover.php</code> I have:</p>

<pre><code>&lt;?php

namespace Commerce\Adjusters;
use Craft\Commerce_LineItemModel;
use Craft\Commerce_OrderAdjustmentModel;
use Craft\Commerce_OrderModel;

class BusinessLogic_TaxRemover implements Commerce_AdjusterInterface {

    public function adjust(Commerce_OrderModel &amp;$order, array $lineItems = []){

        $myAdjuster = new Commerce_OrderAdjustmentModel();

        $order-&gt;baseDiscount = $order-&gt;baseDiscount - 5;

        $myAdjuster-&gt;type = "Test";
        $myAdjuster-&gt;name = "Test Adjuster";
        $myAdjuster-&gt;description = "Takes $5 off the order";
        $myAdjuster-&gt;amount = -5.0;
        $myAdjuster-&gt;orderId = $order-&gt;id;

        //if your Adjuster affects lineItems rather than the total, you record the ids here
        $myAdjuster-&gt;optionsJson = ['lineItemsAffected'=&gt;null];
        $myAdjuster-&gt;included = false;

        return [$myAdjuster];

    }

}
</code></pre>

<p>But whenever doing anything to the cart, I just get the error:</p>

<pre><code>Error

Class 'Craft\BusinessLogic_TaxRemover' not found

C:\Users\clive\Desktop\repos\_craft\craft\plugins\businesslogic\BusinessLogicPlugin.php(38)

26     }
27 
28     public function getDeveloperUrl()
29     {
30         return '';
31     }
32 
33     public function init()
34     {
35     }
36     public function commerce_registerOrderAdjusters(){
37            return [
38             new BusinessLogic_TaxRemover
39             
40            ];
41     }
42 
43 }
</code></pre>

<plugin-craftcommerce><plugins><adjusters>
Getting started with Order Adjuster plugin
# Getting started with Order Adjuster plugin

(Asked by: username_0 on 2017-04-03)

Starting with the Business Logic plugin from https://github.com/lindseydiloreto/craft-businesslogic I'm following 3 for 2 etc with Craft Commerce to get started.
I have my main plugin file containing:
getSiteName();
    }

    public function getDeveloperUrl()
    {
        return '';
    }

    public function init()
    {
    }

    public function commerce_registerOrderAdjusters(){

        return [

            new Commerce_TaxAdjuster

        ];
    }

}

And within Adjusters/BusinessLogic_TaxRemover.php I have:
baseDiscount = $order->baseDiscount - 5;

        $myAdjuster->type = "Test";
        $myAdjuster->name = "Test Adjuster";
        $myAdjuster->description = "Takes $5 off the order";
        $myAdjuster->amount = -5.0;
        $myAdjuster->orderId = $order->id;

        //if your Adjuster affects lineItems rather than the total, you record the ids here
        $myAdjuster->optionsJson = ['lineItemsAffected'=>null];
        $myAdjuster->included = false;

        return [$myAdjuster];

    }

}

But whenever doing anything to the cart, I just get the error:
Error

Class 'Craft\BusinessLogic_TaxRemover' not found

C:\Users\clive\Desktop\repos\_craft\craft\plugins\businesslogic\BusinessLogicPlugin.php(38)

26     }
27 
28     public function getDeveloperUrl()
29     {
30         return '';
31     }
32 
33     public function init()
34     {
35     }
36     public function commerce_registerOrderAdjusters(){
37            return [
38             new BusinessLogic_TaxRemover
39             
40            ];
41     }
42 
43 }

**Tags:** plugin-craftcommerce, plugins, adjusters

---

## 2 answers

### Answer by username_1 on 2017-04-03. Score: 4 | Accepted answer

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 Adjuster class file. 
You can do this (at least) two ways:
include or require the adjuster file in your main plugin class
e.g.

OR you can use Craft::import (which is probably the better way I guess?)
Craft::import('plugins.businesslogic.adjusters.BusinessLogic_TaxRemover');

** The Classname must match the filename **
So e.g. in this case

You must also finally register your Adjuster with commerce 
And again you must use the same classname (and be mindful of namespaces!)
So in this example:
public function commerce_registerOrderAdjusters(){
    return [
        new \Commerce\Adjusters\BusinessLogic_TaxRemover

    ];
}

> **Comments:**
> **username_0**: I think I've done that already, within the init() function?  
> **username_0**: I've also tried `require_once('adjusters/GiftVouchers_Adjusters.php');` after defining the `namespace`. Neither seem to do anything so I think it must be a routing issue.  
> **username_1**: Yeah looking at it on a bigger screen, Brad is right.  I use e.g.  ``` <?php namespace Craft;  require_once('Adjusters/BusinessLogic_TaxRemover.php'); ``` ...at the top, that works.  But my file name is Adjusters/BusinessLogic_TaxRemover.php  
> **username_1**: (the import arrpoach will work too, with the right name)  
> **username_0**: I don't suppose you have a project on GitHub available that has this working code? I've put mine here if that helps: https://github.com/cliveportman/craftcommerce-adjuster  
> **username_1**: Ok I have edited my answer above to show all the things you must do to get an adjuster working...if you follow all of that, it will work for sure...I've tested it :)  Not up on github I'm afraid, it's part of a project....but it definitely works  
> **username_0**: Can I check "So in this case a folder off the main plugin folder:" means a folder within my plugin's folder (e.g. /craft/plugins/businesslogic/Adjusters/) and not a new folder within /craft (e.g. /craft/Adjusters)?  
> **username_1**: Yep, within the plugin.  What's the exact error you're getting now?  
> **username_0**: I've updated the question - it's the same error.  
> **username_1**: hmm, it really looks exactly as I have it working here now....I'll try and give it a go on windows here in a bit..perhaps it's somehow environmental somehow (but I don't really thing so).  Can you maybe slack me an image of your plugins whole folder structure as a check?  
> **username_0**: Nice one Jeremy. PHP7 strikes again. The docs over at https://craftcommerce.com/docs/adjusters should probably be updated, too.  
> **username_1**: Yep will let Luke know  
> **username_2**: It seems like there are some things missing from this thread. What was the PHP7 issue alluded to?  

---

### Answer by username_3 on 2017-04-03. Score: 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`.

> **Comments:**
> **username_0**: I've renamed `adjusters/BusinessLogicAdjusters.php` to `Adjusters/BusinessLogic_TaxRemover.php`, used `require_once('Adjusters/BusinessLogic_TaxRemover.php');` after the namespace in the main plugin file but still no luck. I've edited my question with the updated code.  
> **username_1**: Brad is still on the money here, it's a naming issue still...in this case you have the wrong classname in `commerce_registerOrderAdjusters()` - you need to change that to `new BusinessLogic_TaxRemover` - I put up an issue on your github  
> **username_1**: See my updated answer for a more complete answer...  
> **username_0**: Thanks for you help Jeremy. I've made fixed your issue on Github, correcting the register of the Adjuster, but I get the same error. I think I'd actually tried that previously and had no luck with it. I've updated my question to include the corrected code.  

---

