本文整理汇总了PHP中Tax::checkTaxZone方法的典型用法代码示例。如果您正苦于以下问题:PHP Tax::checkTaxZone方法的具体用法?PHP Tax::checkTaxZone怎么用?PHP Tax::checkTaxZone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tax
的用法示例。
在下文中一共展示了Tax::checkTaxZone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: zoneHasTax
public static function zoneHasTax($id_tax, $id_zone)
{
return Tax::checkTaxZone(intval($id_tax), intval($id_zone));
}
示例2: payment
public function payment()
{
global $cookie, $cart;
$id_currency = (int) Db::getInstance()->getValue('SELECT id_currency FROM `' . _DB_PREFIX_ . 'module_currency` WHERE id_module = ' . (int) $this->id);
if (!$id_currency or $id_currency == -2) {
$id_currency = Configuration::get('PS_CURRENCY_DEFAULT');
} elseif ($id_currency == -1) {
$id_currency = $cart->id_currency;
}
if ($cart->id_currency != $id_currency) {
if (Db::getInstance()->execute('UPDATE ' . _DB_PREFIX_ . 'cart SET id_currency = ' . (int) $id_currency . ' WHERE id_cart = ' . (int) $cart->id)) {
$cart->id_currency = $id_currency;
}
}
$currency = new Currency($id_currency);
$language = new Language($cart->id_lang);
$customer = new Customer($cart->id_customer);
$carrier = new Carrier($cart->id_carrier, $cart->id_lang);
$id_zone = Db::getInstance()->getValue('SELECT id_zone FROM ' . _DB_PREFIX_ . 'address a INNER JOIN ' . _DB_PREFIX_ . 'country c ON a.id_country = c.id_country WHERE id_address = ' . (int) $cart->id_address_delivery);
// Define extracted from mapi/mapi_defs.php
define('HIPAY_GATEWAY_URL', 'https://' . ($this->prod ? '' : 'test.') . 'payment.hipay.com/order/');
require_once dirname(__FILE__) . '/mapi/mapi_package.php';
$paymentParams = new HIPAY_MAPI_PaymentParams();
$paymentParams->setLogin(Configuration::get('HIPAY_ACCOUNT'), Configuration::get('HIPAY_PASSWORD'));
$paymentParams->setAccounts(Configuration::get('HIPAY_ACCOUNT'), Configuration::get('HIPAY_TAX_ACCOUNT') ? Configuration::get('HIPAY_TAX_ACCOUNT') : Configuration::get('HIPAY_ACCOUNT'));
$paymentParams->setDefaultLang(strtolower($language->iso_code) . '_' . strtoupper($language->iso_code));
$paymentParams->setMedia('WEB');
$paymentParams->setRating(Configuration::get('HIPAY_RATING'));
$paymentParams->setPaymentMethod(HIPAY_MAPI_METHOD_SIMPLE);
$paymentParams->setCaptureDay(HIPAY_MAPI_CAPTURE_IMMEDIATE);
$paymentParams->setCurrency(strtoupper($currency->iso_code));
$paymentParams->setIdForMerchant($cart->id);
$paymentParams->setMerchantSiteId(Configuration::get('HIPAY_SITEID'));
$paymentParams->setUrlCancel(Tools::getHttpHost(true, true) . __PS_BASE_URI__ . 'order.php?step=3');
$paymentParams->setUrlNok(Tools::getHttpHost(true, true) . __PS_BASE_URI__ . 'order-confirmation.php?id_cart=' . (int) $cart->id . '&id_module=' . (int) $this->id . '&secure_key=' . $customer->secure_key);
$paymentParams->setUrlOk(Tools::getHttpHost(true, true) . __PS_BASE_URI__ . 'order-confirmation.php?id_cart=' . (int) $cart->id . '&id_module=' . (int) $this->id . '&secure_key=' . $customer->secure_key);
$paymentParams->setUrlAck(Tools::getHttpHost(true, true) . __PS_BASE_URI__ . 'modules/' . $this->name . '/validation.php');
$paymentParams->setBackgroundColor('#FFFFFF');
if (!$paymentParams->check()) {
return $this->l('[Hipay] Error: cannot create PaymentParams');
}
$taxes = array();
$result = Db::getInstance()->executeS('
SELECT DISTINCT t.id_tax, tl.name, t.rate
FROM ' . _DB_PREFIX_ . 'cart_product cp
INNER JOIN ' . _DB_PREFIX_ . 'product p ON cp.id_product = p.id_product
INNER JOIN ' . _DB_PREFIX_ . 'tax t ON p.id_tax = t.id_tax
INNER JOIN ' . _DB_PREFIX_ . 'tax_lang tl ON tl.id_tax = t.id_tax AND tl.id_lang = ' . (int) $cookie->id_lang . '
WHERE cp.id_cart = ' . (int) $cart->id . '
UNION
SELECT t2.id_tax, tl2.name, t2.rate
FROM ' . _DB_PREFIX_ . 'cart c
INNER JOIN ' . _DB_PREFIX_ . 'carrier ca ON c.id_carrier = ca.id_carrier
INNER JOIN ' . _DB_PREFIX_ . 'tax t2 ON ca.id_tax = t2.id_tax
INNER JOIN ' . _DB_PREFIX_ . 'tax_lang tl2 ON tl2.id_tax = t2.id_tax AND tl2.id_lang = ' . (int) $cookie->id_lang . '
WHERE c.id_cart = ' . (int) $cart->id);
foreach ($result as $row) {
$tax = new HIPAY_MAPI_Tax();
$tax->setTaxName($row['name']);
$tax->setTaxVal($row['rate']);
if (!$tax->check()) {
return $this->l('[Hipay] Error: cannot create Tax');
}
$taxes[$row['id_tax']] = $tax;
}
$items = array();
foreach ($cart->getProducts($cookie->id_lang) as $product) {
$item = new HIPAY_MAPI_Product();
$item->setName($product['name']);
$item->setInfo($product['reference']);
$item->setquantity($product['cart_quantity']);
$item->setRef($product['id_product'] . ($product['id_product_attribute'] ? '-' . $product['id_product_attribute'] : ''));
$item->setCategory(Configuration::get('HIPAY_CATEGORY_' . (int) $product['id_category_default']) ? Configuration::get('HIPAY_CATEGORY_' . (int) $product['id_category_default']) : Configuration::get('HIPAY_CATEGORY'));
$price = Product::getPriceStatic($product['id_product'], false, $product['id_product_attribute'], 2, NULL, false, true, $product['cart_quantity']);
$item->setPrice($price);
if (Tax::checkTaxZone($product['id_tax'], $id_zone)) {
$item->setTax(array($taxes[$product['id_tax']]));
}
if (!$item->check()) {
return $this->l('[Hipay] Error: cannot create Product') . ' (' . $product['id_product'] . ($product['id_product_attribute'] ? '-' . $product['id_product_attribute'] : '') . ')';
}
$items[] = $item;
}
foreach ($cart->getDiscounts() as $voucher) {
// For the moment, if there is a couher you can't use hipay
return;
$item = new HIPAY_MAPI_Product();
$item->setName($voucher['name']);
$item->setInfo($voucher['description']);
$item->setquantity(1);
$item->setRef('voucher_' . $voucher['id_discount']);
$item->setCategory(Configuration::get('HIPAY_CATEGORY'));
$item->setPrice(-1 * $voucher['value_real']);
if (!$item->check()) {
return $this->l('[Hipay] Error: cannot create Voucher') . ' (' . $voucher['name'] . ')';
}
$items[] = $item;
}
$order = new HIPAY_MAPI_Order();
$order->setOrderTitle(Configuration::get('PS_SHOP_NAME'));
//.........这里部分代码省略.........