本文整理汇总了PHP中Cart::desintifier方法的典型用法代码示例。如果您正苦于以下问题:PHP Cart::desintifier方法的具体用法?PHP Cart::desintifier怎么用?PHP Cart::desintifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cart
的用法示例。
在下文中一共展示了Cart::desintifier方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _processCarrier
protected function _processCarrier()
{
if (!$this->isOpcModuleActive()) {
return parent::_processCarrier();
}
$reset = false;
if (!$this->context->customer->id) {
$reset = true;
}
if ($reset) {
$this->context->customer->id = 1;
}
// hocijaka nenulova hodnota na osalenie _processCarrier v parentovi
$_POST['delivery_option'][$this->context->cart->id_address_delivery] = Cart::desintifier(Tools::getValue("id_carrier"));
$this->context->cart->id_carrier = Cart::desintifier(Tools::getValue("id_carrier"), '');
$result = parent::_processCarrier();
if ($reset) {
$this->context->customer->id = null;
}
return $result;
}
示例2: _processCarrier
protected function _processCarrier()
{
$this->context->cart->recyclable = (int) Tools::getValue('recyclable');
$this->context->cart->gift = (int) Tools::getValue('gift');
if ((int) Tools::getValue('gift')) {
if (!Validate::isMessage($_POST['gift_message'])) {
$this->errors[] = Tools::displayError('Invalid gift message.');
} else {
$this->context->cart->gift_message = strip_tags($_POST['gift_message']);
}
}
if (isset($this->context->customer->id) && $this->context->customer->id) {
$address = new Address((int) $this->context->cart->id_address_delivery);
if (!($id_zone = Address::getZoneById($address->id))) {
$this->errors[] = Tools::displayError('No zone matches your address.');
}
} else {
$id_zone = Country::getIdZone((int) Configuration::get('PS_COUNTRY_DEFAULT'));
}
if (Tools::getIsset('delivery_option')) {
if ($this->validateDeliveryOption(Tools::getValue('delivery_option'))) {
$this->context->cart->setDeliveryOption(Tools::getValue('delivery_option'));
}
} elseif (Tools::getIsset('id_carrier')) {
// For retrocompatibility reason, try to transform carrier to an delivery option list
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
if (count($delivery_option_list) == 1) {
$delivery_option = reset($delivery_option_list);
$key = Cart::desintifier(Tools::getValue('id_carrier'));
foreach ($delivery_option_list as $id_address => $options) {
if (isset($options[$key])) {
$this->context->cart->id_carrier = (int) Tools::getValue('id_carrier');
$this->context->cart->setDeliveryOption(array($id_address => $key));
if (isset($this->context->cookie->id_country)) {
unset($this->context->cookie->id_country);
}
if (isset($this->context->cookie->id_state)) {
unset($this->context->cookie->id_state);
}
}
}
}
}
Hook::exec('actionCarrierProcess', array('cart' => $this->context->cart));
if (!$this->context->cart->update()) {
return false;
}
// Carrier has changed, so we check if the cart rules still apply
CartRule::autoRemoveFromCart($this->context);
CartRule::autoAddToCart($this->context);
return true;
}
示例3: requestItems
public function requestItems($data)
{
$delivery = array();
$items = $data->cart->items;
if (isset($data->cart->delivery->address)) {
$delivery = $data->cart->delivery->address;
}
if (count($items)) {
if ($delivery) {
$d = $this->addData($data, true, 'cart');
$address = $d['address'];
} else {
$d = $this->addData($data, false, 'cart');
}
$cart = $d['cart'];
$tovar = array();
foreach ($items as $item) {
$id_a = null;
$id = explode('c', $item->offerId);
$product = new Product($id[0], true, $this->context->cookie->id_lang);
if (isset($id[1])) {
$id_a = (int) $id[1];
}
$count_shop = StockAvailable::getQuantityAvailableByProduct($product->id, $id_a);
if (!$product->active || $count_shop < (int) $item->count) {
continue;
}
$count = min($count_shop, (int) $item->count);
if ($id_a) {
$comb = new Combination($id_a);
if ($count < $comb->minimal_quantity) {
continue;
}
} elseif ($count < $product->minimal_quantity) {
continue;
}
$price = Product::getPriceStatic($product->id, null, $id_a);
$result = $cart->updateQty((int) $item->count, (int) $id[0], $id_a);
$total = Tools::ps_round($price, 2);
if ($result) {
$tovar[] = array('feedId' => $item->feedId, 'offerId' => $item->offerId, 'price' => $total, 'count' => (int) $count, 'delivery' => true);
$cart->update();
}
}
$dost = array();
$pm = array();
$types = unserialize(Configuration::get('YA_POKUPKI_CARRIER_SERIALIZE'));
foreach ($cart->simulateCarriersOutput() as $k => $d) {
$id = str_replace(',', '', Cart::desintifier($d['id_carrier']));
$type = isset($types[$id]) ? $types[$id] : 'POST';
$dost[$k] = array('id' => $id, 'serviceName' => $d['name'], 'type' => $type, 'price' => $d['price'], 'dates' => array('fromDate' => date('d-m-Y'), 'toDate' => date('d-m-Y')));
if ($type == 'PICKUP') {
$outlets = $this->getOutlets();
$dost[$k] = array_merge($dost[$k], $outlets['json']);
}
}
if (Configuration::get('YA_POKUPKI_PREDOPLATA_YANDEX')) {
$pm[] = 'YANDEX';
}
if (Configuration::get('YA_POKUPKI_PREDOPLATA_SHOP_PREPAID')) {
$pm[] = 'SHOP_PREPAID';
}
if (Configuration::get('YA_POKUPKI_POSTOPLATA_CASH_ON_DELIVERY')) {
$pm[] = 'CASH_ON_DELIVERY';
}
if (Configuration::get('YA_POKUPKI_POSTOPLATA_CARD_ON_DELIVERY')) {
$pm[] = 'CARD_ON_DELIVERY';
}
$array = array('cart' => array('items' => $tovar, 'deliveryOptions' => $dost, 'paymentMethods' => $pm));
$cart->delete();
$this->context->cookie->logout();
if ($delivery) {
$address->delete();
}
die(Tools::jsonEncode($array));
}
}
示例4: initContent
/**
* Assign template vars related to page content
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
/* id_carrier is not defined in database before choosing a carrier, set it to a default one to match a potential cart _rule */
if (empty($this->context->cart->id_carrier)) {
$checked = $this->context->cart->simulateCarrierSelectedOutput();
$checked = (int) Cart::desintifier($checked);
$this->context->cart->id_carrier = $checked;
$this->context->cart->update();
CartRule::autoRemoveFromCart($this->context);
CartRule::autoAddToCart($this->context);
}
// SHOPPING CART
$this->_assignSummaryInformations();
// WRAPPING AND TOS
$this->_assignWrappingAndTOS();
$selectedCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT');
if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) {
$countries = Carrier::getDeliveredCountries($this->context->language->id, true, true);
} else {
$countries = Country::getCountries($this->context->language->id, true);
}
// If a rule offer free-shipping, force hidding shipping prices
$free_shipping = false;
foreach ($this->context->cart->getCartRules() as $rule) {
if ($rule['free_shipping'] && !$rule['carrier_restriction']) {
$free_shipping = true;
break;
}
}
$this->context->smarty->assign(array('free_shipping' => $free_shipping, 'isGuest' => isset($this->context->cookie->is_guest) ? $this->context->cookie->is_guest : 0, 'countries' => $countries, 'sl_country' => isset($selectedCountry) ? $selectedCountry : 0, 'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'errorCarrier' => Tools::displayError('You must choose a carrier.', false), 'errorTOS' => Tools::displayError('You must accept the Terms of Service.', false), 'isPaymentStep' => (bool) (isset($_GET['isPaymentStep']) && $_GET['isPaymentStep']), 'genders' => Gender::getGenders(), 'one_phone_at_least' => (int) Configuration::get('PS_ONE_PHONE_AT_LEAST'), 'HOOK_CREATE_ACCOUNT_FORM' => Hook::exec('displayCustomerAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Hook::exec('displayCustomerAccountFormTop')));
$years = Tools::dateYears();
$months = Tools::dateMonths();
$days = Tools::dateDays();
$this->context->smarty->assign(array('years' => $years, 'months' => $months, 'days' => $days));
/* Load guest informations */
if ($this->isLogged && $this->context->cookie->is_guest) {
$this->context->smarty->assign('guestInformations', $this->_getGuestInformations());
}
// ADDRESS
if ($this->isLogged) {
$this->_assignAddress();
}
// CARRIER
$this->_assignCarrier();
// PAYMENT
$this->_assignPayment();
Tools::safePostVars();
$blocknewsletter = Module::getInstanceByName('blocknewsletter');
$this->context->smarty->assign('newsletter', (bool) ($blocknewsletter && $blocknewsletter->active));
$this->_processAddressFormat();
$this->setTemplate(_PS_THEME_DIR_ . 'order-opc.tpl');
}
示例5: displayTabContent
public function displayTabContent($id)
{
$partner = new Partner();
$order_ya_db = $this->getYandexOrderById($id);
$html = '';
if ($order_ya_db['id_market_order']) {
$ya_order = $partner->getOrder($order_ya_db['id_market_order']);
$types = unserialize(Configuration::get('YA_POKUPKI_CARRIER_SERIALIZE'));
$state = $ya_order->order->status;
$st = array('PROCESSING', 'DELIVERY', 'PICKUP');
// Tools::d($ya_order);
if (!in_array($state, $st)) {
return false;
}
$this->context->controller->AddJS($this->_path . '/views/js/back.js');
$this->context->controller->AddCss($this->_path . '/views/css/back.css');
$order = new Order($id);
$cart = new Cart($order->id_cart);
$carriers = $cart->simulateCarriersOutput();
$html = '';
$i = 1;
$tmp = array();
$tmp[0]['id_carrier'] = 0;
$tmp[0]['name'] = $this->l('-- Please select carrier --');
foreach ($carriers as $c) {
$id = str_replace(',', '', Cart::desintifier($c['id_carrier']));
$type = isset($types[$id]) ? $types[$id] : 'POST';
if (!Configuration::get('YA_MARKET_SET_ROZNICA') && $type == 'PICKUP') {
continue;
}
$tmp[$i]['id_carrier'] = $id;
$tmp[$i]['name'] = $c['name'];
$i++;
}
if (count($tmp) <= 1) {
return false;
}
$fields_form = array('form' => array('legend' => array('title' => $this->l('Carrier Available'), 'icon' => 'icon-cogs'), 'input' => array('sel_delivery' => array('type' => 'select', 'label' => $this->l('Carrier'), 'name' => 'new_carrier', 'required' => true, 'default_value' => 0, 'class' => 't sel_delivery', 'options' => array('query' => $tmp, 'id' => 'id_carrier', 'name' => 'name')), array('col' => 3, 'class' => 't pr_in', 'type' => 'text', 'desc' => $this->l('Carrier price tax incl.'), 'name' => 'price_incl', 'label' => $this->l('Price tax incl.')), array('col' => 3, 'class' => 't pr_ex', 'type' => 'text', 'desc' => $this->l('Carrier price tax excl.'), 'name' => 'price_excl', 'label' => $this->l('Price tax excl.'))), 'buttons' => array('updcarrier' => array('title' => $this->l('Update carrier'), 'name' => 'updcarrier', 'type' => 'button', 'class' => 'btn btn-default pull-right changec_submit', 'icon' => 'process-icon-refresh'))));
$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->table = $this->table;
$helper->module = $this;
$helper->identifier = $this->identifier;
$helper->submit_action = 'submitChangeCarrier';
$helper->currentIndex = AdminController::$currentIndex . '?id_order=' . $order->id . '&vieworder&token=' . Tools::getAdminTokenLite('AdminOrders');
$helper->token = Tools::getAdminTokenLite('AdminOrders');
$helper->tpl_vars['fields_value']['price_excl'] = '';
$helper->tpl_vars['fields_value']['price_incl'] = '';
$helper->tpl_vars['fields_value']['new_carrier'] = 0;
$path_module_http = __PS_BASE_URI__ . 'modules/yamodule/';
$html .= '<div class="change_carr">
<script type="text/javascript">
var notselc = "' . $this->l('Please select carrier') . '";
var ajaxurl = "' . $path_module_http . '";
var idm = "' . (int) $this->context->employee->id . '";
var tkn = "' . Tools::getAdminTokenLite('AdminOrders') . '";
var id_order = "' . (int) $order->id . '";
</script>
<div id="circularG">
<div id="circularG_1" class="circularG"></div>
<div id="circularG_2" class="circularG"></div>
<div id="circularG_3" class="circularG"></div>
<div id="circularG_4" class="circularG"></div>
<div id="circularG_5" class="circularG"></div>
<div id="circularG_6" class="circularG"></div>
<div id="circularG_7" class="circularG"></div>
<div id="circularG_8" class="circularG"></div>
</div>';
$html .= $helper->generateForm(array($fields_form)) . '</div>';
}
return $html;
}
示例6: initContent
/**
* Assign template vars related to page content
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
/* id_carrier is not defined in database before choosing a carrier, set it to a default one to match a potential cart _rule */
if (empty($this->context->cart->id_carrier)) {
$checked = $this->context->cart->simulateCarrierSelectedOutput();
$checked = (int) Cart::desintifier($checked);
$this->context->cart->id_carrier = $checked;
$this->context->cart->update();
CartRule::autoRemoveFromCart($this->context);
CartRule::autoAddToCart($this->context);
}
// SHOPPING CART
$this->_assignSummaryInformations();
// WRAPPING AND TOS
$this->_assignWrappingAndTOS();
if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) {
$countries = Carrier::getDeliveredCountries($this->context->language->id, true, true);
} else {
$countries = Country::getCountries($this->context->language->id, true);
}
// If a rule offer free-shipping, force hidding shipping prices
$free_shipping = false;
foreach ($this->context->cart->getCartRules() as $rule) {
if ($rule['free_shipping'] && !$rule['carrier_restriction']) {
$free_shipping = true;
break;
}
}
$this->context->smarty->assign(array('free_shipping' => $free_shipping, 'isGuest' => isset($this->context->cookie->is_guest) ? $this->context->cookie->is_guest : 0, 'countries' => $countries, 'sl_country' => (int) Tools::getCountry(), 'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'errorCarrier' => Tools::displayError('You must choose a carrier.', false), 'errorTOS' => Tools::displayError('You must accept the Terms of Service.', false), 'isPaymentStep' => isset($_GET['isPaymentStep']) && $_GET['isPaymentStep'], 'genders' => Gender::getGenders(), 'one_phone_at_least' => (int) Configuration::get('PS_ONE_PHONE_AT_LEAST'), 'HOOK_CREATE_ACCOUNT_FORM' => Hook::exec('displayCustomerAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Hook::exec('displayCustomerAccountFormTop')));
$years = Tools::dateYears();
$months = Tools::dateMonths();
$days = Tools::dateDays();
$this->context->smarty->assign(array('years' => $years, 'months' => $months, 'days' => $days));
/* Load guest informations */
if ($this->isLogged && $this->context->cookie->is_guest) {
$this->context->smarty->assign('guestInformations', $this->_getGuestInformations());
}
// ADDRESS
if ($this->isLogged) {
$this->_assignAddress();
}
// CARRIER
$this->_assignCarrier();
// PAYMENT
$this->_assignPayment();
Tools::safePostVars();
$newsletter = Configuration::get('PS_CUSTOMER_NWSL') || Module::isInstalled('blocknewsletter') && Module::getInstanceByName('blocknewsletter')->active;
$this->context->smarty->assign('newsletter', $newsletter);
$this->context->smarty->assign('optin', (bool) Configuration::get('PS_CUSTOMER_OPTIN'));
$this->context->smarty->assign('field_required', $this->context->customer->validateFieldsRequiredDatabase());
$this->_processAddressFormat();
$link = new Link();
if (Tools::getValue('deleteFromOrderLine')) {
$id_product = Tools::getValue('id_product');
$date_from = Tools::getValue('date_from');
$date_to = Tools::getValue('date_to');
$obj_cart_bk_data = new HotelCartBookingData();
$cart_data_dlt = $obj_cart_bk_data->deleteRoomDataFromOrderLine($this->context->cart->id, $this->context->cart->id_guest, $id_product, $date_from, $date_to);
if ($cart_data_dlt) {
Tools::redirect($link->getPageLink('order', null, $this->context->language->id));
}
}
if ((bool) Configuration::get('PS_ADVANCED_PAYMENT_API')) {
$this->addJS(_THEME_JS_DIR_ . 'advanced-payment-api.js');
$this->setTemplate(_PS_THEME_DIR_ . 'order-opc-advanced.tpl');
} else {
if (Module::isInstalled('hotelreservationsystem')) {
require_once _PS_MODULE_DIR_ . 'hotelreservationsystem/define.php';
$obj_cart_bk_data = new HotelCartBookingData();
$obj_htl_bk_dtl = new HotelBookingDetail();
$obj_rm_type = new HotelRoomType();
$htl_rm_types = $this->context->cart->getProducts();
if (!empty($htl_rm_types)) {
foreach ($htl_rm_types as $type_key => $type_value) {
$product = new Product($type_value['id_product'], false, $this->context->language->id);
$cover_image_arr = $product->getCover($type_value['id_product']);
if (!empty($cover_image_arr)) {
$cover_img = $this->context->link->getImageLink($product->link_rewrite, $product->id . '-' . $cover_image_arr['id_image'], 'small_default');
} else {
$cover_img = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code . "-default", 'small_default');
}
$unit_price = Product::getPriceStatic($type_value['id_product'], true, null, 6, null, false, true, 1);
if (isset($this->context->customer->id)) {
$cart_bk_data = $obj_cart_bk_data->getOnlyCartBookingData($this->context->cart->id, $this->context->cart->id_guest, $type_value['id_product']);
} else {
$cart_bk_data = $obj_cart_bk_data->getOnlyCartBookingData($this->context->cart->id, $this->context->cart->id_guest, $type_value['id_product']);
}
$rm_dtl = $obj_rm_type->getRoomTypeInfoByIdProduct($type_value['id_product']);
$cart_htl_data[$type_key]['id_product'] = $type_value['id_product'];
$cart_htl_data[$type_key]['cover_img'] = $cover_img;
$cart_htl_data[$type_key]['name'] = $product->name;
$cart_htl_data[$type_key]['unit_price'] = $unit_price;
$cart_htl_data[$type_key]['adult'] = $rm_dtl['adult'];
$cart_htl_data[$type_key]['children'] = $rm_dtl['children'];
foreach ($cart_bk_data as $data_k => $data_v) {
//.........这里部分代码省略.........
示例7: _getPaymentMethods
protected function _getPaymentMethods()
{
if (!$this->isOpcModuleActive()) {
return parent::_getPaymentMethods();
}
if ($this->context->cart->OrderExists()) {
$ret = '<p class="warning">' . Tools::displayError('Error: this order has already been validated') . '</p>';
return array("orig_hook" => $ret, "parsed_content" => $ret);
}
$ret = "";
$address_delivery = new Address($this->context->cart->id_address_delivery);
$address_invoice = $this->context->cart->id_address_delivery == $this->context->cart->id_address_invoice ? $address_delivery : new Address($this->context->cart->id_address_invoice);
if (!$this->context->cart->id_address_delivery || !$this->context->cart->id_address_invoice || !Validate::isLoadedObject($address_delivery) || !Validate::isLoadedObject($address_invoice) || $address_invoice->deleted || $address_delivery->deleted) {
$ret = '<p class="warning">' . Tools::displayError('Error: please choose an address') . '</p>';
}
if (count($this->context->cart->getDeliveryOptionList()) == 0 && !$this->context->cart->isVirtualCart()) {
if ($this->context->cart->isMultiAddressDelivery()) {
$ret .= '<p class="warning">' . Tools::displayError('Error: There are no carriers available that deliver to some of your addresses') . '</p>';
} else {
$ret .= '<p class="warning">' . Tools::displayError('Error: There are no carriers available that deliver to this address') . '</p>';
}
}
if (!$this->context->cart->getDeliveryOption(null, false) && !$this->context->cart->isVirtualCart()) {
$ret = '<p class="warning">' . Tools::displayError('Error: please choose a carrier') . '</p>';
}
if (!$this->context->cart->id_currency) {
$ret .= '<p class="warning">' . Tools::displayError('Error: no currency has been selected') . '</p>';
}
if (!$this->context->cart->checkQuantities()) {
$ret .= '<p class="warning">' . Tools::displayError('An item in your cart is no longer available, you cannot proceed with your order.') . '</p>';
}
$currency = Currency::getCurrency((int) $this->context->cart->id_currency);
$minimalPurchase = Tools::convertPrice((double) Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimalPurchase) {
$ret .= '<p class="warning">' . sprintf(Tools::displayError('A minimum purchase total of %s is required in order to validate your order.'), Tools::displayPrice($minimalPurchase, $currency)) . '</p>';
}
if (trim($ret) != "") {
return array("orig_hook" => $ret, "parsed_content" => $ret);
}
$opc_config = $this->context->smarty->tpl_vars["opc_config"]->value;
$tmp_customer_id_1 = isset($opc_config) && isset($opc_config["payment_customer_id"]) ? intval($opc_config["payment_customer_id"]) : 0;
$reset_id_customer = false;
if (!$this->context->cookie->id_customer) {
$simulated_customer_id = $tmp_customer_id_1 > 0 ? $tmp_customer_id_1 : Customer::getFirstCustomerId();
$this->context->cookie->id_customer = $simulated_customer_id;
$reset_id_customer = true;
if (!$this->context->customer->id) {
$this->context->customer->id = $simulated_customer_id;
}
}
$orig_context_country = $this->context->country;
if (isset($address_invoice) && $address_invoice != null) {
$this->context->country = new Country($address_invoice->id_country);
}
if ($this->context->cart->getOrderTotal() <= 0) {
$return = $this->context->smarty->fetch($this->opc_templates_path . '/free-order-payment.tpl');
} else {
$ship2pay_support = isset($opc_config) && isset($opc_config["ship2pay"]) && $opc_config["ship2pay"] == "1" ? true : false;
if ($ship2pay_support) {
$orig_id_carrier = $this->context->cart->id_carrier;
$selected_carrier = Cart::desintifier($this->context->cart->simulateCarrierSelectedOutput());
$selected_carrier = explode(",", $selected_carrier);
$selected_carrier = $selected_carrier[0];
$this->context->cart->id_carrier = $selected_carrier;
$this->context->cart->update();
$return = Hook::exec('displayPayment');
} else {
$return = Hook::exec('displayPayment');
}
}
$this->context->country = $orig_context_country;
# restore cookie's id_customer
if ($reset_id_customer) {
unset($this->context->cookie->id_customer);
$this->context->customer->id = null;
}
# fix Moneybookers relative path to images
$return = preg_replace('/src="modules\\//', 'src="' . __PS_BASE_URI__ . 'modules/', $return);
# OPCKT fix Paypal relative path to redirect script
$return = preg_replace('/href="modules\\//', 'href="' . __PS_BASE_URI__ . 'modules/', $return);
if (!$return) {
$ret = '<p class="warning">' . Tools::displayError('No payment method is available') . '</p>';
return array("orig_hook" => $ret, "parsed_content" => $ret);
}
$parsed_content = "";
$parse_payment_methods = isset($opc_config) && isset($opc_config["payment_radio_buttons"]) && $opc_config["payment_radio_buttons"] == "1" ? true : false;
if ($parse_payment_methods) {
$content = $return;
$payment_methods = array();
$i = 0;
preg_match_all('/<a.*?>[^>]*?<img[^>]*?src="(.*?)".*?\\/?>(.*?)<\\/a>/ms', $content, $matches1, PREG_SET_ORDER);
$tmp_return = preg_replace_callback('/(<(a))([^>]*?>[^>]*?<img.*?src)/ms', array($this, "_genPaymentModId"), $return);
if ($tmp_return == NULL) {
echo "ERRoR!";
}
if ($tmp_return != null) {
// NULL can be returned on backtrace limit exhaustion
$return = $tmp_return;
}
preg_match_all('/<input [^>]*?type="image".*?src="(.*?)".*?>.*?<span.*?>(.*?)<\\/span>/ms', $content, $matches2, PREG_SET_ORDER);
//.........这里部分代码省略.........
示例8: _getPaymentMethods
protected function _getPaymentMethods()
{
if (!$this->isOpcModuleActive()) {
return parent::_getPaymentMethods();
}
if ($this->context->cart->OrderExists()) {
$ret = '<p class="warning">' . Tools::displayError('Error: this order has already been validated') . '</p>';
return array("orig_hook" => $ret, "parsed_content" => $ret);
}
$ret = "";
$address_delivery = new Address($this->context->cart->id_address_delivery);
$address_invoice = $this->context->cart->id_address_delivery == $this->context->cart->id_address_invoice ? $address_delivery : new Address($this->context->cart->id_address_invoice);
if (!$this->context->cart->id_address_delivery || !$this->context->cart->id_address_invoice || !Validate::isLoadedObject($address_delivery) || !Validate::isLoadedObject($address_invoice) || $address_invoice->deleted || $address_delivery->deleted) {
$ret = '<p class="warning">' . Tools::displayError('Error: please choose an address') . '</p>';
}
if (count($this->context->cart->getDeliveryOptionList()) == 0 && !$this->context->cart->isVirtualCart()) {
if ($this->context->cart->isMultiAddressDelivery()) {
$ret .= '<p class="warning">' . Tools::displayError('Error: There are no carriers available that deliver to some of your addresses') . '</p>';
} else {
$ret .= '<p class="warning">' . Tools::displayError('Error: There are no carriers available that deliver to this address') . '</p>';
}
}
if (!$this->context->cart->getDeliveryOption(null, false) && !$this->context->cart->isVirtualCart()) {
$ret = '<p class="warning">' . Tools::displayError('Error: please choose a carrier') . '</p>';
}
if (!$this->context->cart->id_currency) {
$ret .= '<p class="warning">' . Tools::displayError('Error: no currency has been selected') . '</p>';
}
//if (!$this->context->cookie->checkedTOS && Configuration::get('PS_CONDITIONS'))
// return '<p class="warning">'.Tools::displayError('Please accept the Terms of Service').'</p>';
/* If some products have disappear */
if (!$this->context->cart->checkQuantities()) {
$ret .= '<p class="warning">' . Tools::displayError('An item in your cart is no longer available, you cannot proceed with your order.') . '</p>';
}
/* Check minimal amount */
$currency = Currency::getCurrency((int) $this->context->cart->id_currency);
$minimalPurchase = Tools::convertPrice((double) Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimalPurchase) {
$ret .= '<p class="warning">' . sprintf(Tools::displayError('A minimum purchase total of %s is required in order to validate your order.'), Tools::displayPrice($minimalPurchase, $currency)) . '</p>';
}
/* Bypass payment step if total is 0 */
//if ($this->context->cart->getOrderTotal() <= 0)
// $ret .= '<p class="center"><input type="button" class="exclusive_large" name="confirmOrder" id="confirmOrder" value="' . Tools::displayError('I confirm my order') . '" onclick="confirmFreeOrder();" /></p>';
if (trim($ret) != "") {
return array("orig_hook" => $ret, "parsed_content" => $ret);
}
$opc_config = $this->context->smarty->tpl_vars["opc_config"]->value;
$tmp_customer_id_1 = isset($opc_config) && isset($opc_config["payment_customer_id"]) ? intval($opc_config["payment_customer_id"]) : 0;
$reset_id_customer = false;
if (!$this->context->cookie->id_customer) {
// if no customer set yet, use OPCKT default customer - created during installation
$simulated_customer_id = $tmp_customer_id_1 > 0 ? $tmp_customer_id_1 : Customer::getFirstCustomerId();
$this->context->cookie->id_customer = $simulated_customer_id;
$reset_id_customer = true;
if (!$this->context->customer->id) {
$this->context->customer->id = $simulated_customer_id;
}
}
$orig_context_country = $this->context->country;
if (isset($address_invoice) && $address_invoice != null) {
$this->context->country = new Country($address_invoice->id_country);
}
/* Bypass payment step if total is 0 */
if ($this->context->cart->getOrderTotal() <= 0) {
$return = $this->context->smarty->fetch($this->opc_templates_path . '/free-order-payment.tpl');
} else {
$ship2pay_support = isset($opc_config) && isset($opc_config["ship2pay"]) && $opc_config["ship2pay"] == "1" ? true : false;
if ($ship2pay_support) {
$orig_id_carrier = $this->context->cart->id_carrier;
$selected_carrier = Cart::desintifier($this->context->cart->simulateCarrierSelectedOutput());
$selected_carrier = explode(",", $selected_carrier);
$selected_carrier = $selected_carrier[0];
$this->context->cart->id_carrier = $selected_carrier;
$this->context->cart->update();
//$return = $this->_hookExecPaymentShip2pay($tmp_id_carrier);
$return = Hook::exec('displayPayment');
//$this->context->cart->id_carrier = $orig_id_carrier;
} else {
$return = Hook::exec('displayPayment');
}
//$return = Module::hookExecPayment();
}
$this->context->country = $orig_context_country;
# restore cookie's id_customer
if ($reset_id_customer) {
unset($this->context->cookie->id_customer);
$this->context->customer->id = null;
}
# fix Moneybookers relative path to images
$return = preg_replace('/src="modules\\//', 'src="' . __PS_BASE_URI__ . 'modules/', $return);
# OPCKT fix Paypal relative path to redirect script
$return = preg_replace('/href="modules\\//', 'href="' . __PS_BASE_URI__ . 'modules/', $return);
if (!$return) {
$ret = '<p class="warning">' . Tools::displayError('No payment method is available') . '</p>';
return array("orig_hook" => $ret, "parsed_content" => $ret);
}
// if radio buttons as payment turned on, parse payment methods, generate radio buttons and
// hide original buttons; add large green checkout / submit button and also ensure on onepage.js
// that after clicking that button appropriate payment button is pressed.
$parsed_content = "";
//.........这里部分代码省略.........
示例9: simulateSelection
public function simulateSelection($carrier_id, $params)
{
$id_carrier = (int) Cart::desintifier($carrier_id, '');
$cart_data = array();
$cart_data['price'] = (double) $this->context->cart->getPackageShippingCost($id_carrier);
$cart_data['order_total'] = (double) $this->context->cart->getOrderTotal() - (double) $this->context->cart->getTotalShippingCost();
$cart_data['total_tax'] = (double) $this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS) - (double) $this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) + (double) $this->context->cart->getPackageShippingCost($id_carrier, true) - (double) $this->context->cart->getPackageShippingCost($id_carrier, false);
$cart_data['params'] = $params;
return $cart_data;
}