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:
<?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()->getSiteName();
}
public function getDeveloperUrl()
{
return '';
}
public function init()
{
}
public function commerce_registerOrderAdjusters(){
return [
new Commerce_TaxAdjuster
];
}
}
And within Adjusters/BusinessLogic_TaxRemover.php
I have:
<?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 &$order, array $lineItems = []){
$myAdjuster = new Commerce_OrderAdjustmentModel();
$order->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 }