本文整理汇总了PHP中Discount::validateFieldsLang方法的典型用法代码示例。如果您正苦于以下问题:PHP Discount::validateFieldsLang方法的具体用法?PHP Discount::validateFieldsLang怎么用?PHP Discount::validateFieldsLang使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Discount
的用法示例。
在下文中一共展示了Discount::validateFieldsLang方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createOrderDiscount
public static function createOrderDiscount($order, $productList, $qtyList, $name, $shipping_cost = false, $id_category = 0, $subcategory = 0)
{
$languages = Language::getLanguages($order);
$products = $order->getProducts(false, $productList, $qtyList);
// Totals are stored in the order currency (or at least should be)
$total = $order->getTotalProductsWithTaxes($products);
$discounts = $order->getDiscounts(true);
$total_tmp = $total;
foreach ($discounts as $discount) {
if ($discount['id_discount_type'] == 1) {
$total -= $total_tmp * ($discount['value'] / 100);
} elseif ($discount['id_discount_type'] == 2) {
$total -= $discount['value'] * ($total_tmp / $order->total_products_wt);
}
}
if ($shipping_cost) {
$total += $order->total_shipping;
}
// create discount
$voucher = new Discount();
$voucher->id_discount_type = 2;
foreach ($languages as $language) {
$voucher->description[$language['id_lang']] = strval($name) . (int) $order->id;
}
$voucher->value = (double) $total;
$voucher->name = 'V0C' . (int) $order->id_customer . 'O' . (int) $order->id;
$voucher->id_customer = (int) $order->id_customer;
$voucher->id_currency = (int) $order->id_currency;
$voucher->quantity = 1;
$voucher->quantity_per_user = 1;
$voucher->cumulable = 1;
$voucher->cumulable_reduction = 1;
$voucher->minimal = (double) $voucher->value;
$voucher->active = 1;
$voucher->cart_display = 1;
$now = time();
$voucher->date_from = date('Y-m-d H:i:s', $now);
$voucher->date_to = date('Y-m-d H:i:s', $now + 3600 * 24 * 365.25);
/* 1 year */
if (!$voucher->validateFieldsLang(false) or !$voucher->add()) {
return false;
}
// set correct name
$voucher->name = 'V' . (int) $voucher->id . 'C' . (int) $order->id_customer . 'O' . $order->id;
if (!$voucher->update()) {
return false;
}
return $voucher;
}
示例2: createOrderDiscount
public static function createOrderDiscount($order, $productList, $qtyList, $name, $shipping_cost = false, $id_category = 0, $subcategory = 0)
{
$languages = Language::getLanguages($order);
$products = $order->getProducts(false, $productList, $qtyList);
$total = $order->getTotalProductsWithTaxes($products);
if ($shipping_cost) {
$total += $order->total_shipping;
}
// create discount
$voucher = new Discount();
$voucher->id_discount_type = 2;
foreach ($languages as $language) {
$voucher->description[$language['id_lang']] = strval($name) . intval($order->id);
}
$voucher->value = floatval($total);
$voucher->name = 'V0C' . intval($order->id_customer) . 'O' . intval($order->id);
$voucher->id_customer = intval($order->id_customer);
$voucher->quantity = 1;
$voucher->quantity_per_user = 1;
$voucher->cumulable = 1;
$voucher->cumulable_reduction = 1;
$voucher->minimal = floatval($voucher->value);
$voucher->active = 1;
$now = time();
$voucher->date_from = date('Y-m-d H:i:s', $now);
$voucher->date_to = date('Y-m-d H:i:s', $now + 60 * 60 * 24 * 184);
if (!$voucher->validateFieldsLang(false) or !$voucher->add()) {
return false;
}
// set correct name
$voucher->name = 'V' . intval($voucher->id) . 'C' . intval($order->id_customer) . 'O' . $order->id;
if (!$voucher->update()) {
return false;
}
return $voucher;
}
示例3: Discount
}
$cart->addCartRule($voucher->id);
} else {
$voucher = new Discount();
$voucher->id_discount_type = 2;
$voucher->value = $amount;
$languages = Language::getLanguages(true);
$voucher->name = 'Fid\'Bag';
$voucher->description = 'Discount Fid\'Bag';
$voucher->id_customer = (int) $cart->id_customer;
$voucher->id_currency = (int) $cart->id_currency;
$voucher->quantity = 1;
$voucher->quantity_per_user = 1;
$voucher->cumulable = 1;
$voucher->cumulable_reduction = 1;
$voucher->minimal = (double) $voucher->value;
$voucher->include_tax = 1;
$voucher->active = 1;
$voucher->cart_display = 1;
$now = time();
$voucher->date_from = date('Y-m-d H:i:s', $now);
$voucher->date_to = date('Y-m-d H:i:s', $now + 3600 * 24 * 365.25);
if (!$voucher->validateFieldsLang(false) || !$voucher->add()) {
die('0');
}
$cart->addDiscount($voucher->id);
Discount::getVouchersToCartDisplay(1, $cart->id_customer);
}
}
$values = array('total' => Tools::ps_round($cart->getOrderTotal(), $currency->decimals), 'discount' => $amount);
die(Tools::jsonEncode($values));
示例4: addCoupons
public static function addCoupons($idCustomer)
{
global $cookie;
if ((int) $cookie->id_country === 110) {
$vouchers = array("6" => array('INR 300 off on order over INR 1500', Tools::ps_round(Tools::convertPrice(300, Currency::getCurrencyInstance(4), false)), Tools::ps_round(Tools::convertPrice(1500, Currency::getCurrencyInstance(4), false)), 3600 * 24 * 30 * 1), "7" => array('INR 700 off on order over INR 3000', Tools::ps_round(Tools::convertPrice(700, Currency::getCurrencyInstance(4), false)), Tools::ps_round(Tools::convertPrice(3000, Currency::getCurrencyInstance(4), false)), 3600 * 24 * 30 * 1), "8" => array('INR 1500 off on order over INR 5000', Tools::ps_round(Tools::convertPrice(1500, Currency::getCurrencyInstance(4), false)), Tools::ps_round(Tools::convertPrice(5000, Currency::getCurrencyInstance(4), false)), 3600 * 24 * 30 * 1));
} else {
$vouchers = array("6" => array('USD 15 off on order over USD 100', 15, 100.0, 3600 * 24 * 30 * 1), "7" => array('USD 30 off on order over USD 200', 30, 200.0, 3600 * 24 * 30 * 2), "8" => array('USD 55 off on order over USD 300', 55, 300.0, 3600 * 24 * 30 * 3));
}
foreach ($vouchers as $idCoupon => $coupon) {
$couponCode = "" . $idCustomer . $idCoupon . Tools::rand_string(3);
// create discount
$languages = Language::getLanguages($order);
$voucher = new Discount();
$voucher->id_discount_type = 2;
foreach ($languages as $language) {
$voucher->description[$language['id_lang']] = $coupon[0];
}
// coupon description
$voucher->value = (double) $coupon[1];
// coupon value
$voucher->name = $couponCode;
$voucher->id_customer = $idCustomer;
$voucher->id_currency = 2;
//USD
$voucher->quantity = 1;
$voucher->quantity_per_user = 1;
$voucher->cumulable = 0;
$voucher->cumulable_reduction = 1;
$voucher->minimal = (double) $coupon[2];
// min order value
$voucher->active = 1;
$voucher->cart_display = 1;
$now = time();
$voucher->date_from = date('Y-m-d H:i:s', $now);
$voucher->date_to = date('Y-m-d H:i:s', $now + $coupon[3]);
//validity
if (!$voucher->validateFieldsLang(false) or !$voucher->add()) {
return false;
}
}
}