本文整理汇总了PHP中Tools::convertPriceFull方法的典型用法代码示例。如果您正苦于以下问题:PHP Tools::convertPriceFull方法的具体用法?PHP Tools::convertPriceFull怎么用?PHP Tools::convertPriceFull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tools
的用法示例。
在下文中一共展示了Tools::convertPriceFull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initContent
public function initContent()
{
parent::initContent();
$this->paypal = new PayPal();
$this->context = Context::getContext();
$this->id_module = (int) Tools::getValue('id_module');
$this->id_order = (int) Tools::getValue('id_order');
$order = new Order($this->id_order);
$order_state = new OrderState($order->current_state);
$paypal_order = PayPalOrder::getOrderById($this->id_order);
if ($order_state->template[$this->context->language->id] == 'payment_error') {
$this->context->smarty->assign(array('message' => $order_state->name[$this->context->language->id], 'logs' => array($this->paypal->l('An error occurred while processing payment.')), 'order' => $paypal_order, 'price' => Tools::displayPrice($paypal_order['total_paid'], $this->context->currency)));
return $this->setTemplate('error.tpl');
}
$order_currency = new Currency((int) $order->id_currency);
$display_currency = new Currency((int) $this->context->currency->id);
$price = Tools::convertPriceFull($paypal_order['total_paid'], $order_currency, $display_currency);
$this->context->smarty->assign(array('is_guest' => $this->context->customer->is_guest || $this->context->customer->id == false, 'order' => $paypal_order, 'price' => Tools::displayPrice($price, $this->context->currency->id), 'HOOK_ORDER_CONFIRMATION' => $this->displayOrderConfirmation(), 'HOOK_PAYMENT_RETURN' => $this->displayPaymentReturn()));
if ($this->context->customer->is_guest || $this->context->customer->id == false) {
$this->context->smarty->assign(array('id_order' => (int) $this->id_order, 'id_order_formatted' => sprintf('#%06d', (int) $this->id_order), 'order_reference' => $order->reference));
/* If guest we clear the cookie for security reason */
$this->context->customer->mylogout();
}
if ($this->context->getMobileDevice() == true) {
$this->setTemplate('order-confirmation-mobile.tpl');
} else {
$this->setTemplate('order-confirmation.tpl');
}
}
示例2: initContent
public function initContent()
{
$cart = $this->context->cart;
$payments = array();
$payments['message'] = $this->module->l('The order status is not paid! Go to my account and then reorder');
if ($cart) {
$total_to_pay = $cart->getOrderTotal(true);
$rub_currency_id = Currency::getIdByIsoCode('RUB');
if ($cart->id_currency != $rub_currency_id) {
$from_currency = new Currency($cart->id_curre1ncy);
$to_currency = new Currency($rub_currency_id);
$total_to_pay = Tools::convertPriceFull($total_to_pay, $from_currency, $to_currency);
}
$display = '';
if (Configuration::get('YA_P2P_ACTIVE')) {
$vars_p2p = Configuration::getMultiple(array('YA_P2P_NUMBER', 'YA_P2P_ACTIVE'));
$this->context->smarty->assign(array('DATA_P2P' => $vars_p2p, 'price' => number_format($total_to_pay, 2, '.', ''), 'cart' => $this->context->cart));
$display .= $this->display(__FILE__, 'payment.tpl');
}
if (Configuration::get('YA_ORG_ACTIVE')) {
$vars_org = Configuration::getMultiple(array('YA_ORG_SHOPID', 'YA_ORG_SCID', 'YA_ORG_ACTIVE', 'YA_ORG_TYPE'));
$this->context->smarty->assign(array('DATA_ORG' => $vars_org, 'id_cart' => $cart->id, 'customer' => new Customer($cart->id_customer), 'address' => new Address($this->context->cart->id_address_delivery), 'total_to_pay' => number_format($total_to_pay, 2, '.', ''), 'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->module->name . '/', 'shop_name' => Configuration::get('PS_SHOP_NAME')));
$payments = Configuration::getMultiple(array('YA_ORG_PAYMENT_YANDEX', 'YA_ORG_PAYMENT_CARD', 'YA_ORG_PAYMENT_MOBILE', 'YA_ORG_PAYMENT_WEBMONEY', 'YA_ORG_PAYMENT_TERMINAL', 'YA_ORG_PAYMENT_SBER', 'YA_ORG_PAYMENT_PB', 'YA_ORG_PAYMENT_MA', 'YA_ORG_PAYMENT_ALFA'));
if (Configuration::get('YA_ORG_INSIDE')) {
$payments['pt'] = Tools::getValue('type');
} else {
$payments['pt'] = '';
}
}
}
$this->context->smarty->assign($payments);
return $this->setTemplate('redirectk.tpl');
}
示例3: initContent
public function initContent()
{
$cart = $this->context->cart;
$payments = array();
$payments['message'] = $this->module->l('Заказ в статусе не оплачен! Перейдите в личный кабинет и нажмите перезаказ');
if ($cart) {
$total_to_pay = $cart->getOrderTotal(true);
$rub_currency_id = Currency::getIdByIsoCode('RUB');
if ($cart->id_currency != $rub_currency_id) {
$from_currency = new Currency($cart->id_curre1ncy);
$to_currency = new Currency($rub_currency_id);
$total_to_pay = Tools::convertPriceFull($total_to_pay, $from_currency, $to_currency);
}
$display = '';
if (Configuration::get('YA_P2P_ACTIVE')) {
$vars_p2p = Configuration::getMultiple(array('YA_P2P_NUMBER', 'YA_P2P_ACTIVE'));
$this->context->smarty->assign(array('DATA_P2P' => $vars_p2p, 'price' => number_format($total_to_pay, 2, '.', ''), 'cart' => $this->context->cart));
$display .= $this->display(__FILE__, 'payment.tpl');
}
if (Configuration::get('YA_ORG_ACTIVE')) {
$vars_org = Configuration::getMultiple(array('YA_ORG_SHOPID', 'YA_ORG_SCID', 'YA_ORG_ACTIVE', 'YA_ORG_TYPE'));
$this->context->smarty->assign(array('DATA_ORG' => $vars_org, 'id_cart' => $cart->id, 'customer' => new Customer($cart->id_customer), 'address' => new Address($this->context->cart->id_address_delivery), 'total_to_pay' => number_format($total_to_pay, 2, '.', ''), 'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->module->name . '/', 'shop_name' => Configuration::get('PS_SHOP_NAME')));
$payments = Configuration::getMultiple(array('YA_ORG_PAYMENT_YANDEX', 'YA_ORG_PAYMENT_CARD', 'YA_ORG_PAYMENT_MOBILE', 'YA_ORG_PAYMENT_WEBMONEY', 'YA_ORG_PAYMENT_TERMINAL', 'YA_ORG_PAYMENT_SBER', 'YA_ORG_PAYMENT_PB', 'YA_ORG_PAYMENT_MA', 'YA_ORG_PAYMENT_ALFA'));
$payments['pt'] = Tools::getValue('type');
}
//$this->module->validateOrder((int)$cart->id, _PS_OS_PREPARATION_, $cart->getOrderTotal(true, Cart::BOTH), $this->module->displayName, NULL, array(), NULL, false, $cart->secure_key);
}
$this->context->smarty->assign($payments);
return $this->setTemplate('redirectk.tpl');
}
示例4: initContent
/**
* Assign template vars related to page content
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
$cart_rules = CartRule::getCustomerCartRules($this->context->language->id, $this->context->customer->id, true, false);
$nb_cart_rules = count($cart_rules);
foreach ($cart_rules as &$discount) {
$discount['value'] = Tools::convertPriceFull($discount['value'], new Currency((int) $discount['reduction_currency']), new Currency((int) $this->context->cart->id_currency));
}
$this->context->smarty->assign(array('nb_cart_rules' => (int) $nb_cart_rules, 'cart_rules' => $cart_rules, 'discount' => $cart_rules, 'nbDiscounts' => (int) $nb_cart_rules));
$this->setTemplate(_PS_THEME_DIR_ . 'discount.tpl');
}
示例5: postProcess
public function postProcess()
{
parent::postProcess();
$log_on = Configuration::get('YA_P2P_LOGGING_ON');
$cart = $this->context->cart;
if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
Tools::redirect('index.php?controller=order&step=1');
}
$customer = new Customer($cart->id_customer);
if (!Validate::isLoadedObject($customer)) {
Tools::redirect('index.php?controller=order&step=1');
}
$this->myCart = $this->context->cart;
$total_to_pay = $cart->getOrderTotal(true);
$rub_currency_id = Currency::getIdByIsoCode('RUB');
if ($cart->id_currency != $rub_currency_id) {
$from_currency = new Currency($cart->id_currency);
$to_currency = new Currency($rub_currency_id);
$total_to_pay = Tools::convertPriceFull($total_to_pay, $from_currency, $to_currency);
}
if ($total_to_pay > 0 && $total_to_pay < 1) {
$total_to_pay_limit = '1.00';
} else {
$total_to_pay_limit = number_format($total_to_pay, 2, '.', '');
}
$total_to_pay = number_format($total_to_pay, 2, '.', '');
$this->module->payment_status = '';
$code = Tools::getValue('code');
$type = Tools::getValue('type');
if (empty($code)) {
$scope = array("payment.to-account(\"" . Configuration::get('YA_P2P_NUMBER') . "\",\"account\").limit(," . $total_to_pay_limit . ")", "money-source(\"wallet\",\"card\")");
if ($type == 'wallet') {
if ($log_on) {
$this->module->log_save('p2p_redirect: ' . $this->module->l('Type wallet'));
}
$auth_url = API::buildObtainTokenUrl(Configuration::get('YA_P2P_IDENTIFICATOR'), $this->context->link->getModuleLink('yamodule', 'redirect_wallet', array(), true), $scope);
} elseif ($type == 'card') {
if ($log_on) {
$this->module->log_save('redirect: ' . $this->module->l('Type card'));
}
Tools::redirect($this->context->link->getModuleLink('yamodule', 'redirect_card', array('code' => true, 'cnf' => true), true), '');
}
if ($log_on) {
$this->module->log_save('p2p_redirect: url = ' . $auth_url);
}
Tools::redirect($auth_url, '');
}
}
示例6: assignPriceAndTax
/**
* Assign price and tax to the template
*/
protected function assignPriceAndTax()
{
die('coucou');
$id_customer = isset($this->context->customer) ? (int) $this->context->customer->id : 0;
$id_group = (int) Group::getCurrent()->id;
$id_country = $id_customer ? (int) Customer::getCurrentCountry($id_customer) : (int) Tools::getCountry();
$group_reduction = GroupReduction::getValueForProduct($this->product->id, $id_group);
if ($group_reduction === false) {
$group_reduction = Group::getReduction((int) $this->context->cookie->id_customer) / 100;
}
// Tax
$tax = (double) $this->product->getTaxesRate(new Address((int) $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
$this->context->smarty->assign('tax_rate', $tax);
$product_price_with_tax = Product::getPriceStatic($this->product->id, true, null, 6) * 10;
if (Product::$_taxCalculationMethod == PS_TAX_INC) {
$product_price_with_tax = Tools::ps_round($product_price_with_tax, 2);
}
$product_price_without_eco_tax = (double) $product_price_with_tax - $this->product->ecotax;
$ecotax_rate = (double) Tax::getProductEcotaxRate($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$ecotax_tax_amount = Tools::ps_round($this->product->ecotax, 2);
if (Product::$_taxCalculationMethod == PS_TAX_INC && (int) Configuration::get('PS_TAX')) {
$ecotax_tax_amount = Tools::ps_round($ecotax_tax_amount * (1 + $ecotax_rate / 100), 2);
}
$id_currency = (int) $this->context->cookie->id_currency;
$id_product = (int) $this->product->id;
$id_shop = $this->context->shop->id;
$quantity_discounts = SpecificPrice::getQuantityDiscounts($id_product, $id_shop, $id_currency, $id_country, $id_group, null, true, (int) $this->context->customer->id);
foreach ($quantity_discounts as &$quantity_discount) {
if ($quantity_discount['id_product_attribute']) {
$combination = new Combination((int) $quantity_discount['id_product_attribute']);
$attributes = $combination->getAttributesName((int) $this->context->language->id);
foreach ($attributes as $attribute) {
$quantity_discount['attributes'] = $attribute['name'] . ' - ';
}
$quantity_discount['attributes'] = rtrim($quantity_discount['attributes'], ' - ');
}
if ((int) $quantity_discount['id_currency'] == 0 && $quantity_discount['reduction_type'] == 'amount') {
$quantity_discount['reduction'] = Tools::convertPriceFull($quantity_discount['reduction'], null, Context::getContext()->currency);
}
}
$product_price = $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false) * 10;
$address = new Address($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$this->context->smarty->assign(array('quantity_discounts' => $this->formatQuantityDiscounts($quantity_discounts, $product_price, (double) $tax, $ecotax_tax_amount), 'ecotax_tax_inc' => $ecotax_tax_amount, 'ecotax_tax_exc' => Tools::ps_round($this->product->ecotax, 2), 'ecotaxTax_rate' => $ecotax_rate, 'productPriceWithoutEcoTax' => (double) $product_price_without_eco_tax, 'group_reduction' => $group_reduction, 'no_tax' => Tax::excludeTaxeOption() || !$this->product->getTaxesRate($address), 'ecotax' => !count($this->errors) && $this->product->ecotax > 0 ? Tools::convertPrice((double) $this->product->ecotax) : 0, 'tax_enabled' => Configuration::get('PS_TAX') && !Configuration::get('AEUC_LABEL_TAX_INC_EXC'), 'customer_group_without_tax' => Group::getPriceDisplayMethod($this->context->customer->id_default_group)));
}
示例7: initContent
/**
* Assign template vars related to page content
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
$cart_rules = CartRule::getCustomerCartRules($this->context->language->id, $this->context->customer->id, true, true, true);
$nb_cart_rules = count($cart_rules);
foreach ($cart_rules as $key => &$discount) {
if ($discount['quantity_for_user'] === 0) {
unset($cart_rules[$key]);
}
$discount['value'] = Tools::convertPriceFull($discount['value'], new Currency((int) $discount['reduction_currency']), new Currency((int) $this->context->cart->id_currency));
if ($discount['gift_product'] !== 0) {
$product = new Product((int) $discount['gift_product']);
if (isset($product->name)) {
$discount['gift_product_name'] = current($product->name);
}
}
}
$this->context->smarty->assign(array('nb_cart_rules' => (int) $nb_cart_rules, 'cart_rules' => $cart_rules, 'discount' => $cart_rules, 'nbDiscounts' => (int) $nb_cart_rules));
$this->setTemplate(_PS_THEME_DIR_ . 'discount.tpl');
}
示例8: getOrderShippingCostExternal
public function getOrderShippingCostExternal($cart)
{
if (!$this->soapClientExists() || !$this->checkModuleAvailability()) {
return false;
}
$disabled_countries_ids = DpdPolandCountry::getDisabledCountriesIDs();
$id_country = (int) Tools::getValue('id_country');
if (!$id_country) {
$country = Address::getCountryAndState((int) $cart->id_address_delivery);
$id_country = $country['id_country'];
}
if (!($id_method = self::getMethodIdByCarrierId($this->id_carrier))) {
self::$carriers[$this->id_carrier] = false;
return false;
}
if (!$id_country || in_array($id_country, $disabled_countries_ids) && $id_method == _DPDPOLAND_CLASSIC_ID_) {
return false;
}
if ($id_country) {
$zone = Country::getIdZone($id_country);
} else {
return false;
}
if (!$this->id_carrier) {
return false;
}
if ($id_country == Country::getByIso(self::POLAND_ISO_CODE) && $id_method == _DPDPOLAND_CLASSIC_ID_ || $id_country != Country::getByIso(self::POLAND_ISO_CODE) && $id_method == _DPDPOLAND_STANDARD_COD_ID_ || $id_country != Country::getByIso(self::POLAND_ISO_CODE) && $id_method == _DPDPOLAND_STANDARD_ID_) {
return false;
}
if (isset(self::$carriers[$this->id_carrier])) {
return self::$carriers[$this->id_carrier];
}
$total_weight = self::convertWeight($cart->getTotalWeight());
if (Configuration::get(DpdPolandConfiguration::PRICE_CALCULATION_TYPE) == DpdPolandConfiguration::PRICE_CALCULATION_PRESTASHOP) {
$carrier = new Carrier($this->id_carrier);
$price = $carrier->getDeliveryPriceByWeight($total_weight, $zone);
self::$carriers[$this->id_carrier] = $price;
return self::$carriers[$this->id_carrier];
}
$price = DpdPolandCSV::getPrice($total_weight, $id_method, $cart);
if ($price === false) {
return false;
}
$id_currency_pl = Currency::getIdByIsoCode(_DPDPOLAND_CURRENCY_ISO_, (int) $this->context->shop->id);
$currency_from = new Currency((int) $id_currency_pl);
$currency_to = $this->context->currency;
self::$carriers[$this->id_carrier] = Tools::convertPriceFull($price, $currency_from, $currency_to);
return self::$carriers[$this->id_carrier];
}
示例9: hookdisplayPayment
public function hookdisplayPayment($params)
{
if (!$this->active) {
return;
}
if (!$this->_checkCurrency($params['cart'])) {
return;
}
$cart = $this->context->cart;
$total_to_pay = $cart->getOrderTotal(true);
$rub_currency_id = Currency::getIdByIsoCode('RUB');
if ($cart->id_currency != $rub_currency_id) {
$from_currency = new Currency($cart->id_curre1ncy);
$to_currency = new Currency($rub_currency_id);
$total_to_pay = Tools::convertPriceFull($total_to_pay, $from_currency, $to_currency);
}
$display = '';
if (Configuration::get('YA_P2P_ACTIVE')) {
$vars_p2p = Configuration::getMultiple(array('YA_P2P_NUMBER', 'YA_P2P_ACTIVE'));
$this->context->smarty->assign(array('DATA_P2P' => $vars_p2p, 'price' => number_format($total_to_pay, 2, '.', ''), 'cart' => $this->context->cart));
$display .= $this->display(__FILE__, 'payment.tpl');
}
if (Configuration::get('YA_ORG_ACTIVE')) {
$vars_org = Configuration::getMultiple(array('YA_ORG_SHOPID', 'YA_ORG_SCID', 'YA_ORG_ACTIVE', 'YA_ORG_TYPE'));
$this->context->smarty->assign(array('DATA_ORG' => $vars_org, 'id_cart' => $params['cart']->id, 'customer' => new Customer($params['cart']->id_customer), 'address' => new Address($this->context->cart->id_address_delivery), 'total_to_pay' => number_format($total_to_pay, 2, '.', ''), 'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->name . '/', 'shop_name' => Configuration::get('PS_SHOP_NAME')));
$payments = Configuration::getMultiple(array('YA_ORG_PAYMENT_YANDEX', 'YA_ORG_PAYMENT_CARD', 'YA_ORG_PAYMENT_MOBILE', 'YA_ORG_PAYMENT_WEBMONEY', 'YA_ORG_PAYMENT_TERMINAL', 'YA_ORG_PAYMENT_SBER', 'YA_ORG_PAYMENT_PB', 'YA_ORG_PAYMENT_MA', 'YA_ORG_PAYMENT_QW', 'YA_ORG_PAYMENT_QP', 'YA_ORG_PAYMENT_ALFA'));
if ($payments['YA_ORG_PAYMENT_YANDEX']) {
$this->smarty->assign(array('pt' => 'PC', 'buttontext' => $this->l('Оплата из кошелька в Яндекс.Деньгах.')));
$display .= $this->display(__FILE__, 'kassa.tpl');
}
if ($payments['YA_ORG_PAYMENT_CARD']) {
$this->smarty->assign(array('pt' => 'AC', 'buttontext' => $this->l('Оплата с произвольной банковской карты.')));
$display .= $this->display(__FILE__, 'kassa.tpl');
}
if ($payments['YA_ORG_PAYMENT_MOBILE']) {
$this->smarty->assign(array('pt' => 'MC', 'buttontext' => $this->l('Платеж со счета мобильного телефона.')));
$display .= $this->display(__FILE__, 'kassa.tpl');
}
if ($payments['YA_ORG_PAYMENT_WEBMONEY']) {
$this->smarty->assign(array('pt' => 'WM', 'buttontext' => $this->l('Оплата из кошелька в системе WebMoney.')));
$display .= $this->display(__FILE__, 'kassa.tpl');
}
if ($payments['YA_ORG_PAYMENT_TERMINAL']) {
$this->smarty->assign(array('pt' => 'GP', 'buttontext' => $this->l('Оплата наличными через кассы и терминалы.')));
$display .= $this->display(__FILE__, 'kassa.tpl');
}
if ($payments['YA_ORG_PAYMENT_SBER']) {
$this->smarty->assign(array('pt' => 'SB', 'buttontext' => $this->l('Оплата через Сбербанк: оплата по SMS или Сбербанк Онлайн.')));
$display .= $this->display(__FILE__, 'kassa.tpl');
}
if ($payments['YA_ORG_PAYMENT_ALFA']) {
$this->smarty->assign(array('pt' => 'AB', 'buttontext' => $this->l('Оплата через Альфа-Клик.')));
$display .= $this->display(__FILE__, 'kassa.tpl');
}
if ($payments['YA_ORG_PAYMENT_PB']) {
$this->smarty->assign(array('pt' => 'PB', 'buttontext' => $this->l('Оплата через Промсвязьбанк.')));
$display .= $this->display(__FILE__, 'kassa.tpl');
}
if ($payments['YA_ORG_PAYMENT_MA']) {
$this->smarty->assign(array('pt' => 'MA', 'buttontext' => $this->l('Оплата через MasterPass.')));
$display .= $this->display(__FILE__, 'kassa.tpl');
}
if ($payments['YA_ORG_PAYMENT_QW']) {
$this->smarty->assign(array('pt' => 'QW', 'buttontext' => $this->l('Оплата через QIWI Wallet.')));
$display .= $this->display(__FILE__, 'kassa.tpl');
}
if ($payments['YA_ORG_PAYMENT_QP']) {
$this->smarty->assign(array('pt' => 'QP', 'buttontext' => $this->l('Оплата через доверительный платеж (Куппи.ру).')));
$display .= $this->display(__FILE__, 'kassa.tpl');
}
}
$this->context->smarty->assign(array('this_path' => $this->_path, 'this_path_ssl' => Tools::getHttpHost(true, true) . __PS_BASE_URI__ . 'modules/' . $this->name . '/'));
return $display;
}
示例10: postProcess
public function postProcess()
{
parent::postProcess();
$this->log_on = Configuration::get('YA_P2P_LOGGING_ON');
$cart = $this->context->cart;
if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
Tools::redirect('index.php?controller=order&step=1');
}
$customer = new Customer($cart->id_customer);
if (!Validate::isLoadedObject($customer)) {
Tools::redirect('index.php?controller=order&step=1');
}
$this->myCart = $this->context->cart;
$total_to_pay = $cart->getOrderTotal(true);
$rub_currency_id = Currency::getIdByIsoCode('RUB');
if ($cart->id_currency != $rub_currency_id) {
$from_currency = new Currency($cart->id_currency);
$to_currency = new Currency($rub_currency_id);
$total_to_pay = Tools::convertPriceFull($total_to_pay, $from_currency, $to_currency);
}
if ($total_to_pay > 0 && $total_to_pay < 1) {
$total_to_pay_limit = '1.00';
} else {
$total_to_pay_limit = number_format($total_to_pay, 2, '.', '');
}
$total_to_pay = number_format($total_to_pay, 2, '.', '');
$this->module->payment_status = false;
$code = Tools::getValue('code');
$cnf = Tools::getValue('cnf');
if (empty($code)) {
Tools::redirect('index.php?controller=order&step=3');
} elseif (!empty($code) && $cnf) {
$comment = $message = $this->module->l('total:') . $total_to_pay . $this->module->l(' rub');
$response = API::getAccessToken(Configuration::get('YA_P2P_IDENTIFICATOR'), $code, $this->context->link->getModuleLink('yamodule', 'redirect', array(), true), Configuration::get('YA_P2P_KEY'));
$token = $response->access_token;
if ($token == '') {
$scope = array("payment.to-account(\"" . Configuration::get('YA_P2P_NUMBER') . "\",\"account\").limit(," . $total_to_pay_limit . ")", "money-source(\"wallet\",\"card\")");
if ($this->log_on) {
$this->module->log_save('wallet_redirect: ' . $this->module->l('Type wallet'));
}
$auth_url = API::buildObtainTokenUrl(Configuration::get('YA_P2P_IDENTIFICATOR'), $this->context->link->getModuleLink('yamodule', 'redirect_wallet', array(), true), $scope);
if ($this->log_on) {
$this->module->log_save('wallet_redirect: url = ' . $auth_url);
}
Tools::redirect($auth_url, '');
}
$api = new API($token);
$rarray = array('pattern_id' => 'p2p', 'to' => Configuration::get('YA_P2P_NUMBER'), 'amount_due' => $total_to_pay, 'comment' => trim($comment), 'message' => trim($message), 'label' => $this->context->cart->id);
$request_payment = $api->requestPayment($rarray);
switch ($request_payment->status) {
case 'success':
if ($this->log_on) {
$this->module->log_save('wallet_redirect: ' . $this->module->l('request success'));
}
$this->context->cookie->ya_encrypt_token = urlencode(base64_encode($token));
$this->context->cookie->ya_encrypt_RequestId = urlencode(base64_encode($request_payment->request_id));
$this->context->cookie->write();
$this->module->payment_link = $this->context->link->getModuleLink('yamodule', 'redirect', array(), true);
do {
$process_payment = $api->processPayment(array("request_id" => $request_payment->request_id));
if ($process_payment->status == "in_progress") {
sleep(1);
}
} while ($process_payment->status == "in_progress");
$this->updateStatus($process_payment);
$this->error = false;
break;
case 'refused':
if ($this->log_on) {
$this->module->log_save('wallet_redirect: ' . $this->module->l('request refused'));
}
$this->errors[] = $this->module->descriptionError($request_payment->error);
if ($this->log_on) {
$this->module->log_save('wallet_redirect: refused ' . $this->module->descriptionError($request_payment->error));
}
$this->error = true;
break;
case 'hold_for_pickup':
if ($this->log_on) {
$this->module->log_save('wallet_redirect: ' . $this->module->l('hold_for_pickup'));
}
$this->errors[] = $this->module->l('Получатель перевода не найден, будет отправлен перевод до востребования. Успешное выполнение.');
if ($this->log_on) {
$this->module->log_save('wallet_redirect: hold_for_pickup ' . $this->module->l('Получатель перевода не найден, будет отправлен перевод до востребования. Успешное выполнение.'));
}
$this->error = true;
break;
}
}
}
示例11: convertPriceFull
public static function convertPriceFull($amount, $currency_from = null, $currency_to = null)
{
if (version_compare(_PS_VERSION_, '1.5', '>')) {
return Tools::convertPriceFull($amount, $currency_from, $currency_to);
} else {
if ($currency_from === $currency_to) {
return $amount;
}
if ($currency_from === null) {
$currency_from = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
}
if ($currency_to === null) {
$currency_to = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
}
if ($currency_from->id == Configuration::get('PS_CURRENCY_DEFAULT')) {
$amount *= $currency_to->conversion_rate;
} else {
$conversion_rate = $currency_from->conversion_rate == 0 ? 1 : $currency_from->conversion_rate;
// Convert amount to default currency (using the old currency rate)
$amount = Tools::ps_round($amount / $conversion_rate, 2);
// Convert to new currency
$amount *= $currency_to->conversion_rate;
}
return Tools::ps_round($amount, 2);
}
}
示例12: getTotal
private function getTotal($device_currency_code, $order_currency_id, $total)
{
$this->setContext();
$device_currency = Currency::getCurrencyInstance($device_currency_code);
if ($device_currency_code != $order_currency_id) {
$currency_from = Currency::getCurrencyInstance($order_currency_id);
$total = Tools::convertPriceFull($total, $currency_from, $device_currency);
}
$total = Tools::displayPrice($total, $device_currency);
return $total;
}
示例13: postProcess
public function postProcess()
{
parent::postProcess();
$dd = serialize($_REQUEST);
$this->log_on = Configuration::get('YA_ORG_LOGGING_ON');
if ($this->log_on) {
$this->module->log_save('payment_kassa ' . $dd);
}
Tools::getValue('label') ? $data = explode('_', Tools::getValue('label')) : ($data = explode('_', Tools::getValue('customerNumber')));
if (!empty($data) && $data[0] == 'KASSA') {
$cart = new Cart($data[1]);
if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
Tools::redirect('index.php?controller=order&step=1');
}
$customer = new Customer($cart->id_customer);
if (!Validate::isLoadedObject($customer)) {
Tools::redirect('index.php?controller=order&step=1');
}
$total_to_pay = $cart->getOrderTotal(true);
$rub_currency_id = Currency::getIdByIsoCode('RUB');
if ($cart->id_currency != $rub_currency_id) {
$from_currency = new Currency($cart->id_currency);
$to_currency = new Currency($rub_currency_id);
$total_to_pay = Tools::convertPriceFull($total_to_pay, $from_currency, $to_currency);
}
$total_to_pay = number_format($total_to_pay, 2, '.', '');
$amount = Tools::getValue('orderSumAmount');
$action = Tools::getValue('action');
$shopId = Tools::getValue('shopId');
$invoiceId = Tools::getValue('invoiceId');
$signature = md5($action . ';' . $amount . ';' . Tools::getValue('orderSumCurrencyPaycash') . ';' . Tools::getValue('orderSumBankPaycash') . ';' . $shopId . ';' . $invoiceId . ';' . Tools::getValue('customerNumber') . ';' . trim(Configuration::get('YA_ORG_MD5_PASSWORD')));
$ord = $cart->orderExists() ? new Order((int) Order::getOrderByCartId($cart->id)) : $this->module->validateOrder($cart->id, _PS_OS_PREPARATION_, $cart->getOrderTotal(true, Cart::BOTH), $this->module->displayName, NULL, array(), NULL, false, $cart->secure_key);
if (!$ord) {
$this->module->validateResponse($this->module->l('Invalid order number'), 1, $action, $shopId, $invoiceId, true);
}
if (Tools::strtoupper($signature) != Tools::strtoupper(Tools::getValue('md5'))) {
$this->module->validateResponse($this->module->l('Invalid signature'), 1, $action, $shopId, $invoiceId, true);
}
if ($amount != $total_to_pay) {
$this->module->validateResponse($this->module->l('Incorrect payment amount'), $action == 'checkOrder' ? 100 : 200, $action, $shopId, $invoiceId, true);
}
if ($action == 'checkOrder') {
if ($this->log_on) {
$this->module->log_save('payment_kassa: checkOrder invoiceId="' . $invoiceId . '" shopId="' . $shopId . '" ' . $this->module->l('check order'));
}
$this->module->validateResponse('', 0, $action, $shopId, $invoiceId, true);
}
if ($action == 'paymentAviso') {
$history = new OrderHistory();
$history->id_order = $ord->id;
$history->changeIdOrderState(Configuration::get('PS_OS_PAYMENT'), $ord->id);
$history->addWithemail(true);
if ($this->log_on) {
$this->module->log_save('payment_kassa: paymentAviso invoiceId="' . $invoiceId . '" shopId="' . $shopId . '" #' . $ord->id . ' ' . $this->module->l('Order success'));
}
$this->module->validateResponse('', 0, $action, $shopId, $invoiceId, true);
}
} else {
Tools::redirect('index.php?controller=order&step=3');
}
}
示例14: convertPriceFull
public static function convertPriceFull($amount, Currency $currency_from = null, Currency $currency_to = null, $round = true)
{
if ($round) {
return Tools::convertPriceFull($amount, $currency_from, $currency_to);
}
if ($currency_from === $currency_to) {
return $amount;
}
if ($currency_from === null) {
$currency_from = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
}
if ($currency_to === null) {
$currency_to = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
}
if ($currency_from->id == Configuration::get('PS_CURRENCY_DEFAULT')) {
$amount *= $currency_to->conversion_rate;
} else {
$conversion_rate = $currency_from->conversion_rate == 0 ? 1 : $currency_from->conversion_rate;
// Convert amount to default currency (using the old currency rate)
$amount = $amount / $conversion_rate;
// Convert to new currency
$amount *= $currency_to->conversion_rate;
}
return $amount;
}
示例15: getProductAttributesOther
function getProductAttributesOther($products)
{
return $products;
if ($products) {
$currency = new Currency($this->context->currency->id);
$timeNow = time();
$http = 'http';
if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
$http .= "s";
}
$http .= "://";
foreach ($products as $i => &$product) {
$product['image'] = Context::getContext()->link->getImageLink($product['link_rewrite'], $product['id_image'], 'home_default');
if (strpos($product['image'], $http) === false) {
$product['image'] = $http . $product['image'];
}
$product['price_new'] = number_format(Tools::convertPriceFull($product['price'], $currency), 2, '.', ',');
$product['price_old'] = '0';
$product['reduction'] = '';
if ($product['specific_prices']) {
$from = strtotime($product['specific_prices']['from']);
$to = strtotime($product['specific_prices']['to']);
if ($product['specific_prices']['from_quantity'] == '1' && ($timeNow >= $from && $timeNow <= $to || $product['specific_prices']['to'] == '0000-00-00 00:00:00')) {
$product['price_old'] = number_format(Tools::convertPriceFull($product['price_without_reduction'], $currency), 2, '.', ',');
if ($product['specific_prices']['reduction_type'] == 'percentage') {
$product['reduction'] = $product['specific_prices']['reduction'] * 100 . '%';
} else {
$product['reduction'] = number_format(Tools::convertPriceFull($product['specific_prices']['reduction'], $currency), 2, '.', ',');
}
}
}
$product['rates'] = '';
$product['totalRates'] = '0';
if (Module::isInstalled('productcomments') == 1) {
$productRate = $this->getProductRatings($product['id_product']);
if (isset($productRate) && $productRate['avg'] > 0) {
if ($productRate['total'] > 1) {
$product['totalRates'] = $productRate['total'] . 's';
} else {
$product['totalRates'] = $productRate['total'];
}
for ($i = 0; $i < 5; $i++) {
if ($productRate['avg'] >= $i) {
$product['rates'] .= '<div class="star"></div>';
} else {
$product['rates'] .= '<div class="star star_off"></div>';
}
}
} else {
$product['rates'] .= '<div class="star star_off"></div>';
$product['rates'] .= '<div class="star star_off"></div>';
$product['rates'] .= '<div class="star star_off"></div>';
$product['rates'] .= '<div class="star star_off"></div>';
$product['rates'] .= '<div class="star star_off"></div>';
}
} else {
$product['rates'] .= '<div class="star star_off"></div>';
$product['rates'] .= '<div class="star star_off"></div>';
$product['rates'] .= '<div class="star star_off"></div>';
$product['rates'] .= '<div class="star star_off"></div>';
$product['rates'] .= '<div class="star star_off"></div>';
}
$product['isCompare'] = 0;
if ($this->compareProductIds) {
if (in_array($product['id_product'], $this->compareProductIds)) {
$product['isCompare'] = 1;
}
}
}
}
return $products;
}