Free shipping for selected countries and/or shipping methods
This commit is contained in:
@@ -31,19 +31,41 @@ class CouponConsumeEvent extends ActionEvent
|
||||
/** @var bool If Coupon is valid or if Customer meets coupon conditions */
|
||||
protected $isValid = null;
|
||||
|
||||
/** @var bool true if coupon offers free shipping */
|
||||
protected $freeShipping = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $code Coupon code
|
||||
* @param float $discount Total discount given by this coupon
|
||||
* @param bool $isValid If Coupon is valid or
|
||||
* if Customer meets coupon conditions
|
||||
* @param bool $isValid If Coupon is valid or f Customer meets coupon conditions
|
||||
* @param bool $freeShipping true if coupon offers free shipping
|
||||
*/
|
||||
public function __construct($code, $discount = null, $isValid = null)
|
||||
public function __construct($code, $discount = null, $isValid = null, $freeShipping = false)
|
||||
{
|
||||
$this->code = $code;
|
||||
$this->discount = $discount;
|
||||
$this->isValid = $isValid;
|
||||
$this->discount = $discount;
|
||||
|
||||
$this->freeShipping = $freeShipping;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $freeShipping
|
||||
*/
|
||||
public function setFreeShipping($freeShipping)
|
||||
{
|
||||
$this->freeShipping = $freeShipping;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function getFreeShipping()
|
||||
{
|
||||
return $this->freeShipping;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -73,6 +73,12 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
/** @var string Language code ISO (ex: fr_FR) */
|
||||
protected $locale = null;
|
||||
|
||||
/** @var array ID of Countries to which shipping is free */
|
||||
protected $freeShippingForCountries;
|
||||
|
||||
/** @var array ID of Shipping modules for which shipping is free */
|
||||
protected $freeShippingForMethods;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@@ -91,8 +97,13 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
* @param boolean $isRemovingPostage Is removing Postage
|
||||
* @param int $maxUsage Coupon quantity
|
||||
* @param string $locale Coupon Language code ISO (ex: fr_FR)
|
||||
* @param array $freeShippingForCountries ID of Countries to which shipping is free
|
||||
* @param array $freeShippingForMethods ID of Shipping modules for which shipping is free
|
||||
*/
|
||||
public function __construct($code, $serviceId, $title, array $effects, $shortDescription, $description, $isEnabled, \DateTime $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $isRemovingPostage, $maxUsage, $locale)
|
||||
public function __construct(
|
||||
$code, $serviceId, $title, array $effects, $shortDescription, $description,
|
||||
$isEnabled, \DateTime $expirationDate, $isAvailableOnSpecialOffers, $isCumulative,
|
||||
$isRemovingPostage, $maxUsage, $locale, $freeShippingForCountries, $freeShippingForMethods)
|
||||
{
|
||||
$this->code = $code;
|
||||
$this->description = $description;
|
||||
@@ -107,6 +118,44 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
$this->serviceId = $serviceId;
|
||||
$this->locale = $locale;
|
||||
$this->setEffects($effects);
|
||||
$this->freeShippingForCountries = $freeShippingForCountries;
|
||||
$this->freeShippingForMethods = $freeShippingForMethods;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $freeShippingForCountries
|
||||
* @return $this
|
||||
*/
|
||||
public function setFreeShippingForCountries($freeShippingForCountries)
|
||||
{
|
||||
$this->freeShippingForCountries = $freeShippingForCountries;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getFreeShippingForCountries()
|
||||
{
|
||||
return $this->freeShippingForCountries;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $freeShippingForMethods
|
||||
* @return $this
|
||||
*/
|
||||
public function setFreeShippingForMethods($freeShippingForMethods)
|
||||
{
|
||||
$this->freeShippingForMethods = $freeShippingForMethods;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getFreeShippingForMethods()
|
||||
{
|
||||
return $this->freeShippingForMethods;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -178,7 +178,9 @@ class Coupon extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
$coupon->getIsAvailableOnSpecialOffers(),
|
||||
$coupon->getIsEnabled(),
|
||||
$coupon->getMaxUsage(),
|
||||
$coupon->getExpirationDate()
|
||||
$coupon->getExpirationDate(),
|
||||
$coupon->getFreeShippingForCountries(),
|
||||
$coupon->getFreeShippingForModules()
|
||||
);
|
||||
|
||||
$cleanedConditions = array();
|
||||
|
||||
@@ -204,9 +204,9 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
case 'discount':
|
||||
return $order->getDiscount();
|
||||
case 'delivery_address':
|
||||
return $order->chosenDeliveryAddress;
|
||||
return $order->getChoosenDeliveryAddress();
|
||||
case 'invoice_address':
|
||||
return $order->chosenInvoiceAddress;
|
||||
return $order->getChoosenInvoiceAddress();
|
||||
case 'delivery_module':
|
||||
return $order->getDeliveryModuleId();
|
||||
case 'payment_module':
|
||||
|
||||
@@ -82,7 +82,7 @@ class Security extends AbstractSmartyPlugin
|
||||
$order = $this->request->getSession()->getOrder();
|
||||
/* Does address and module still exists ? We assume address owner can't change neither module type */
|
||||
if ($order !== null) {
|
||||
$checkAddress = AddressQuery::create()->findPk($order->chosenDeliveryAddress);
|
||||
$checkAddress = AddressQuery::create()->findPk($order->getChoosenDeliveryAddress());
|
||||
$checkModule = ModuleQuery::create()->findPk($order->getDeliveryModuleId());
|
||||
}
|
||||
if (null === $order || null == $checkAddress || null === $checkModule) {
|
||||
|
||||
Reference in New Issue
Block a user