Source of file Simple.php
Size: 1,483 Bytes - Last Modified: 2021-12-24T06:35:03+00:00
/var/www/docs.ssmods.com/process/src/src/Model/Modifiers/Shipping/Simple.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 | <?php namespace SilverShop\Model\Modifiers\Shipping; use SilverStripe\SiteConfig\SiteConfig; /** * Flat shipping to specific countries. * * @package shop * @subpackage modifiers */ class Simple extends Base { /** * @config * @var float */ private static $default_charge = 10; /** * @config * @var array */ private static $charges_by_country = array(); public function value($subtotal = null) { $country = $this->Country(); if ($country && isset(self::config()->charges_by_country[$country])) { return self::config()->charges_by_country[$country]; } return self::config()->default_charge; } public function getTableTitle() { if ($country = $this->Country()) { $countryList = SiteConfig::current_site_config()->getCountriesList(); return _t( __CLASS__ . '.ShipToCountry', 'Ship to {Country}', '', ['Country' => $countryList[$country]] ); } else { return parent::getTableTitle(); } } /** * @return string | null */ public function Country() { if ($order = $this->Order()) { if ($order->getShippingAddress()->exists() && $order->getShippingAddress()->Country) { return $order->getShippingAddress()->Country; } } return null; } } |