Created
January 15, 2019 18:18
-
-
Save fritzmg/ac2d919c261c94b12d36eb18af5e9670 to your computer and use it in GitHub Desktop.
Custom Contao Isotope Surcharge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Register Isotope model types | |
*/ | |
\Isotope\Model\ProductCollectionSurcharge::registerModelType('mysurcharge', \MySurchargeModel::class); | |
/** | |
* Register Isotope hooks | |
*/ | |
$GLOBALS['ISO_HOOKS']['findSurchargesForCollection'][] = [\MySurcharge::class, 'findSurchargesForCollection']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Isotope\Model\ProductCollection; | |
class MySurcharge | |
{ | |
public function findSurchargesForCollection(ProductCollection $collection): array | |
{ | |
return [\MySurchargeModel::build()]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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