Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Custom Contao Isotope Surcharge
<?php
/**
* Register Isotope model types
*/
\Isotope\Model\ProductCollectionSurcharge::registerModelType('mysurcharge', \MySurchargeModel::class);
/**
* Register Isotope hooks
*/
$GLOBALS['ISO_HOOKS']['findSurchargesForCollection'][] = [\MySurcharge::class, 'findSurchargesForCollection'];
<?php
use Isotope\Model\ProductCollection;
class MySurcharge
{
public function findSurchargesForCollection(ProductCollection $collection): array
{
return [\MySurchargeModel::build()];
}
}
<?php
use Isotope\Interfaces\IsotopeProductCollectionSurcharge;
use Isotope\Model\ProductCollectionSurcharge;
class MySurchargeModel extends ProductCollectionSurcharge implements IsotopeProductCollectionSurcharge
{
public static function build(): self
{
$surcharge = new self();
$surcharge->label = 'My Surcharge';
$surcharge->price = '';
$surcharge->total_price = 100.0;
$surcharge->tax_class = 1;
$surcharge->before_tax = true;
$surcharge->addToTotal = true;
return $surcharge;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.