本文整理汇总了PHP中Discount类的典型用法代码示例。如果您正苦于以下问题:PHP Discount类的具体用法?PHP Discount怎么用?PHP Discount使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Discount类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
DB::table('discounts')->truncate();
$discount = new Discount();
$discount->role_id = 5;
//Đại lý chính thức
$discount->branch_id = 1;
//Giày dép
$discount->from_rate = 0;
$discount->to_rate = 3000000;
$discount->percentage = 5;
$discount->save();
$discount = new Discount();
$discount->role_id = 5;
//Đại lý chính thức
$discount->branch_id = 1;
//Giày dép
$discount->from_rate = 3000001;
$discount->to_rate = 6000000;
$discount->percentage = 15;
$discount->save();
$discount = new Discount();
$discount->role_id = 5;
//Đại lý chính thức
$discount->branch_id = 1;
//Giày dép
$discount->from_rate = 6000001;
$discount->to_rate = 300000000;
$discount->percentage = 25;
$discount->save();
}
示例2: createDefaultBcashDiscounts
public function createDefaultBcashDiscounts()
{
foreach ($this->names as $name) {
$coupon = new Discount();
$coupon->name = $this->getLangsForName($name);
$coupon->quantity = self::billion;
$coupon->quantity_per_user = self::billion;
$coupon->date_from = date('Y-m-d H:i:s');
$coupon->date_to = date('Y-m-d', strtotime('+30 year'));
$coupon->partial_use = 0;
$coupon->code = 'gerenciado_pelo_modulo_' . Tools::passwdGen(8);
$coupon->active = 0;
//Invisivel
$coupon->highlight = 0;
//Envio excluido
$coupon->minimum_amount_shipping = 0;
//Acoes
$coupon->free_shipping = 0;
$coupon->reduction_percent = 0;
if ($coupon->add()) {
Configuration::updateValue(self::prefix . self::bcash . $name, (int) $coupon->id);
}
}
return true;
}
示例3: registerDiscount
public function registerDiscount($id_customer, $register = false)
{
$configurations = Configuration::getMultiple(array('REFERRAL_DISCOUNT_TYPE', 'REFERRAL_DISCOUNT_VALUE'));
$discount = new Discount();
$discount->id_discount_type = intval($configurations['REFERRAL_DISCOUNT_TYPE']);
$discount->value = floatval($configurations['REFERRAL_DISCOUNT_VALUE']);
$discount->quantity = 1;
$discount->quantity_per_user = 1;
$discount->date_from = date('Y-m-d H:i:s', time());
$discount->date_to = date('Y-m-d H:i:s', time() + 31536000);
// + 1 year
$discount->name = $this->getDiscountPrefix() . Tools::passwdGen(6);
$discount->description = Configuration::getInt('REFERRAL_DISCOUNT_DESCRIPTION');
$discount->id_customer = intval($id_customer);
if ($discount->add()) {
if ($register != false) {
if ($register == 'sponsor') {
$this->id_discount_sponsor = $discount->id;
} elseif ($register == 'sponsored') {
$this->id_discount = $discount->id;
}
return $this->save();
}
return true;
}
return false;
}
示例4: createDiscountFromEntity
/**
* Create Discount, with applicable DiscountConditions
*/
static function createDiscountFromEntity($entity)
{
$discount = new Discount();
$discount->setId($entity->getId())->setName($entity->getName())->setAs($entity->getAppliedAs())->setTo($entity->getAppliedTo())->setValue($entity->getValue())->setIsPreTax($entity->getIsPreTax())->setIsAuto($entity->getIsAuto())->setCouponCode($entity->getCouponCode());
//TODO: build discount conditions
return $discount;
}
示例5: check
public function check(Discount $discount)
{
$zones = $discount->Zones();
if (!$zones->exists()) {
return true;
}
$address = $this->order->getShippingAddress();
if (!$address) {
$this->error(_t("OrderCouponModifier.NOTINZONE", "This coupon can only be used for a specific shipping location."));
return false;
}
$currentzones = Zone::get_zones_for_address($address);
if (!$currentzones || !$currentzones->exists()) {
$this->error(_t("OrderCouponModifier.NOTINZONE", "This discount can only be used for a specific shipping location."));
return false;
}
//check if any of currentzones is in zones
$inzone = false;
foreach ($currentzones as $zone) {
if ($zones->find('ID', $zone->ID)) {
$inzone = true;
break;
}
}
if (!$inzone) {
$this->error(_t("OrderCouponModifier.NOTINZONE", "This discount can only be used for a specific shipping location."));
return false;
}
return true;
}
示例6: check
public function check(Discount $discount)
{
if ($discount->MinOrderValue > 0 && $this->order->SubTotal() < $discount->MinOrderValue) {
$this->error(sprintf(_t("Discount.MINORDERVALUE", "Your cart subtotal must be at least %s to use this discount"), $discount->dbObject("MinOrderValue")->Nice()));
return false;
}
return true;
}
示例7: check
public function check(Discount $discount)
{
if ($discount->UseLimit) {
if ($discount->getUseCount($this->order->ID) >= $discount->UseLimit) {
$this->error("This discount has reached it's maximum number of uses.");
return false;
}
}
return true;
}
示例8: showDetailData
public function showDetailData()
{
if (isset($_GET['id'])) {
$discount = new Discount();
return $discount->getOneDiscountById($_GET['id']);
} else {
header("location:" . HOME_LINK);
return false;
}
}
示例9: check
public function check(Discount $discount)
{
$group = $discount->Group();
$member = $this->getMember();
if ($group->exists() && (!$member || !$member->inGroup($group))) {
$this->error(_t("Discount.GROUPED", "Only specific members can use this discount."));
return false;
}
return true;
}
示例10: itemMatchesCriteria
public function itemMatchesCriteria(OrderItem $item, Discount $discount)
{
$products = $discount->Products();
$itemproduct = $item->Product(true);
//true forces the current version of product to be retrieved.
if ($products->exists() && !$products->find('ID', $item->ProductID)) {
return false;
}
return true;
}
示例11: check
public function check(Discount $discount)
{
$members = $discount->Members();
$member = $this->getMember();
if ($members->exists() && (!$member || !$members->byID($member->ID))) {
$this->error(_t("Discount.MEMBERSHIP", "Only specific members can use this discount."));
return false;
}
return true;
}
示例12: titleMaker
public function titleMaker()
{
//check if id is set
if (isset($_GET['id'])) {
//if id is set, set the title to the discount title
$id = $_GET['id'];
$discount = new Discount();
$title = $discount->getTitle($id);
return $title['title'];
}
return isset($_GET['page']) ? ucfirst($_GET['page']) : "Homepage";
}
示例13: itemMatchesCriteria
public function itemMatchesCriteria(OrderItem $item, Discount $discount)
{
$discountcategoryids = $discount->Categories()->getIDList();
if (empty($discountcategoryids)) {
return true;
}
//get category ids from buyable
$buyable = $item->Buyable();
if (!method_exists($buyable, "getCategoryIDs")) {
return false;
}
$ids = array_intersect($buyable->getCategoryIDs(), $discountcategoryids);
return !empty($ids);
}
示例14: fromArray
public static function fromArray($data)
{
$item = new InvoiceItem();
if (isset($data['quantity'])) {
$item->setQuantity($data['quantity']);
}
if (isset($data['vat'])) {
$item->setVat($data['vat']);
}
if (isset($data['price_item'])) {
$item->setPriceItem($data['price_item']);
}
if (isset($data['price'])) {
$item->setPrice($data['price']);
}
if (isset($data['price_total'])) {
$item->setPriceTotal($data['price_total']);
}
if (isset($data['description'])) {
$item->setPriceTotal($data['description']);
}
if (isset($data['discount']) && is_array($data['discount'])) {
$item->setDiscount(Discount::fromArray($data['discount']));
}
return $item;
}
示例15: registerDiscount
public function registerDiscount($id_customer, $register = false, $id_currency = 0)
{
$configurations = Configuration::getMultiple(array('REFERRAL_DISCOUNT_TYPE', 'REFERRAL_PERCENTAGE', 'REFERRAL_DISCOUNT_VALUE_' . (int) $id_currency));
$discount = new Discount();
$discount->id_discount_type = (int) $configurations['REFERRAL_DISCOUNT_TYPE'];
/* % */
if ($configurations['REFERRAL_DISCOUNT_TYPE'] == 1) {
$discount->value = (double) $configurations['REFERRAL_PERCENTAGE'];
} elseif ($configurations['REFERRAL_DISCOUNT_TYPE'] == 2 and isset($configurations['REFERRAL_DISCOUNT_VALUE_' . (int) $id_currency])) {
$discount->value = (double) $configurations['REFERRAL_DISCOUNT_VALUE_' . (int) $id_currency];
} else {
$discount->value = 0;
}
$discount->quantity = 1;
$discount->quantity_per_user = 1;
$discount->date_from = date('Y-m-d H:i:s', time());
$discount->date_to = date('Y-m-d H:i:s', time() + 31536000);
// + 1 year
$discount->name = $this->getDiscountPrefix() . Tools::passwdGen(6);
$discount->description = Configuration::getInt('REFERRAL_DISCOUNT_DESCRIPTION');
$discount->id_customer = (int) $id_customer;
$discount->id_currency = (int) $id_currency;
if ($discount->add()) {
if ($register != false) {
if ($register == 'sponsor') {
$this->id_discount_sponsor = (int) $discount->id;
} elseif ($register == 'sponsored') {
$this->id_discount = (int) $discount->id;
}
return $this->save();
}
return true;
}
return false;
}