本文整理汇总了PHP中ProductDownload::getIdFromIdProduct方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductDownload::getIdFromIdProduct方法的具体用法?PHP ProductDownload::getIdFromIdProduct怎么用?PHP ProductDownload::getIdFromIdProduct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProductDownload
的用法示例。
在下文中一共展示了ProductDownload::getIdFromIdProduct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hasProductDownload
public function hasProductDownload($cart)
{
foreach ($cart->getProducts() as $product) {
$pd = ProductDownload::getIdFromIdProduct((int) $product['id_product']);
if ($pd and Validate::isUnsignedInt($pd)) {
return true;
}
}
return false;
}
示例2: hookPayment
public function hookPayment($params)
{
if (!$this->active) {
return;
}
global $smarty;
// Check if cart has product download
foreach ($params['cart']->getProducts() as $product) {
$pd = ProductDownload::getIdFromIdProduct((int) $product['id_product']);
if ($pd and Validate::isUnsignedInt($pd)) {
return false;
}
}
$smarty->assign(array('this_path' => $this->_path, 'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->name . '/'));
return $this->display(__FILE__, 'payment.tpl');
}
示例3: hookPayment
public function hookPayment($params)
{
if (!$this->active) {
return;
}
global $smarty;
// Check if cart has product download
foreach ($params['cart']->getProducts() as $product) {
$pd = ProductDownload::getIdFromIdProduct(intval($product['id_product']));
if ($pd and Validate::isUnsignedInt($pd)) {
return false;
}
}
$smarty->assign(array('this_path' => $this->_path, 'this_path_ssl' => (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://') . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/' . $this->name . '/'));
return $this->display(__FILE__, 'payment.tpl');
}
示例4: addWithemail
public function addWithemail($autodate = true, $templateVars = false)
{
$lastOrderState = $this->getLastOrderState($this->id_order);
if (!parent::add($autodate)) {
return false;
}
$result = Db::getInstance()->getRow('
SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`
FROM `' . _DB_PREFIX_ . 'order_history` oh
LEFT JOIN `' . _DB_PREFIX_ . 'orders` o ON oh.`id_order` = o.`id_order`
LEFT JOIN `' . _DB_PREFIX_ . 'customer` c ON o.`id_customer` = c.`id_customer`
LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON oh.`id_order_state` = os.`id_order_state`
LEFT JOIN `' . _DB_PREFIX_ . 'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = o.`id_lang`)
WHERE oh.`id_order_history` = ' . (int) $this->id . '
AND os.`send_email` = 1');
$order = new Order((int) $this->id_order);
if (isset($result['template']) and Validate::isEmail($result['email'])) {
$topic = $result['osname'];
$data = array('{lastname}' => $result['lastname'], '{firstname}' => $result['firstname'], '{id_order}' => (int) $this->id_order);
if ($templateVars) {
$data = array_merge($data, $templateVars);
}
$data['{total_paid}'] = Tools::displayPrice((double) $order->total_paid, new Currency((int) $order->id_currency), false);
$data['{order_name}'] = sprintf("#%06d", (int) $order->id);
// An additional email is sent the first time a virtual item is validated
if ($virtualProducts = $order->getVirtualProducts() and (!$lastOrderState or !$lastOrderState->logable) and $newOrderState = new OrderState($this->id_order_state, Configuration::get('PS_LANG_DEFAULT')) and $newOrderState->logable) {
global $smarty;
$assign = array();
foreach ($virtualProducts as $key => $virtualProduct) {
$id_product_download = ProductDownload::getIdFromIdProduct($virtualProduct['product_id']);
$product_download = new ProductDownload($id_product_download);
$assign[$key]['name'] = $product_download->display_filename;
$dl_link = $product_download->getTextLink(false, $virtualProduct['download_hash']) . '&id_order=' . $order->id . '&secure_key=' . $order->secure_key;
$assign[$key]['link'] = $dl_link;
if ($virtualProduct['download_deadline'] != '0000-00-00 00:00:00') {
$assign[$key]['deadline'] = Tools::displayDate($virtualProduct['download_deadline'], $order->id_lang);
}
if ($product_download->nb_downloadable != 0) {
$assign[$key]['downloadable'] = $product_download->nb_downloadable;
}
}
$smarty->assign('virtualProducts', $assign);
$smarty->assign('id_order', $order->id);
$iso = Language::getIsoById((int) $order->id_lang);
$links = $smarty->fetch(_PS_MAIL_DIR_ . $iso . '/download-product.tpl');
$tmpArray = array('{nbProducts}' => count($virtualProducts), '{virtualProducts}' => $links);
$data = array_merge($data, $tmpArray);
global $_LANGMAIL;
Mail::Send((int) $order->id_lang, 'download_product', Mail::l('Virtual product to download'), $data, $result['email'], $result['firstname'] . ' ' . $result['lastname']);
}
//custom subjects
$emailSubject = $topic;
$smsText = '';
$delivery = new Address((int) $order->id_address_delivery);
if ($this->id_order_state == _PS_OS_CANCELED_) {
$emailSubject = 'Your order #' . $order->id . ' with IndusDiva.com has been cancelled';
$smsText = 'Dear customer, your order #' . $order->id . ' with IndusDiva.com has been cancelled. www.indusdiva.com';
Tools::sendSMS($delivery->phone_mobile, $smsText);
} else {
if ($this->id_order_state == _PS_OS_REFUND_) {
$emailSubject = 'Refund of your payment at IndusDiva.com';
$smsText = 'Dear customer, an amount of ' . Tools::displayPrice((double) $order->total_paid) . ' has been credited to your account against your order #' . $order->id . ' at IndusDiva.com. www.indusdiva.com';
Tools::sendSMS($delivery->phone_mobile, $smsText);
}
}
if (Validate::isLoadedObject($order)) {
Mail::Send((int) $order->id_lang, $result['template'], $emailSubject, $data, $result['email'], $result['firstname'] . ' ' . $result['lastname']);
}
}
/* Send loyalty rules message */
if ($this->id_order_state == _PS_OS_DELIVERED_) {
$customer = new Customer($order->id_customer);
$customer->total_delivered++;
$customer->update();
Tools::sendSQSRuleMessage(EVENT_ORDER_DELIVERED, $order->id, $order->id_customer, $this->date_add);
} else {
if ($this->id_order_state == _PS_OS_CANCELED_) {
$order_cart = new Cart($order->id_cart);
$points_redeemed = $order_cart->getPoints();
if ($points_redeemed) {
VBRewards::addRewardPoints($order->id_customer, EVENT_ORDER_CANCELLED, 0, $points_redeemed, 'Redemption order cancelled - Order no ' . $order->id, $order->id, $order->date_add);
}
/*
//if online payment bonus awarded
$reward = rule_base::getReward($order->id_customer, ONLINE_ORDER, 0, $order->id);
if($reward)
{
$points_removed = $reward['points_awarded'];
VBRewards::removeRewardPoints($order->id_customer, EVENT_ORDER_CANCELLED, 0, $points_removed, 'Order Cancellation - Bonus coins reverted - Order no ' . $order->id, $order->id, $this->date_add);
}
*/
//if the order was delivered
if ($lastOrderState->id == _PS_OS_DELIVERED_) {
$customer = new Customer($order->id_customer);
$customer->total_delivered--;
$customer->update();
Tools::sendSQSRuleMessage(EVENT_ORDER_CANCELLED, $order->id, $order->id_customer, $this->date_add);
}
} else {
if ($this->id_order_state == _PS_OS_PREPARATION_) {
//.........这里部分代码省略.........
示例5: displayFormInformations
//.........这里部分代码省略.........
);
</script>
</td>
</tr>
<tr>
<td class="col-left">' . $this->l('Reference:') . '</td>
<td style="padding-bottom:5px;">
<input size="55" type="text" name="reference" value="' . htmlentities($this->getFieldValue($obj, 'reference'), ENT_COMPAT, 'UTF-8') . '" style="width: 130px; margin-right: 44px;" />
' . $this->l('EAN13:') . '<input size="55" maxlength="13" type="text" name="ean13" value="' . $this->getFieldValue($obj, 'ean13') . '" style="width: 110px; margin-left: 10px;" />
<span class="hint" name="help_box">' . $this->l('Special characters allowed:') . ' .-_#\\<span class="hint-pointer"> </span></span>
</td>
</tr>
<tr>
<td class="col-left">' . $this->l('Supplier Reference:') . '</td>
<td style="padding-bottom:5px;">
<input size="55" type="text" name="supplier_reference" value="' . htmlentities($this->getFieldValue($obj, 'supplier_reference'), ENT_COMPAT, 'UTF-8') . '" style="width: 130px; margin-right: 44px;" />
' . $this->l('Location:') . '<input size="55" type="text" name="location" value="' . $this->getFieldValue($obj, 'location') . '" style="width: 101px; margin-left: 10px;" />
<span class="hint" name="help_box">' . $this->l('Special characters allowed:') . ' .-_#\\<span class="hint-pointer"> </span></span>
</td>
</tr>
<tr>
<td class="col-left">' . $this->l('Weight:') . '</td>
<td style="padding-bottom:5px;">
<input size="6" maxlength="6" name="weight" type="text" value="' . htmlentities($this->getFieldValue($obj, 'weight'), ENT_COMPAT, 'UTF-8') . '" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\');" /> ' . Configuration::get('PS_WEIGHT_UNIT') . '
</td>
</tr>
<tr><td colspan="2"><hr style="width:730px;"></td></tr>';
$this->displayPack($obj);
echo ' <tr><td colspan="2"><hr style="width:730px;"></td></tr>';
/*
* Form for add a virtual product like software, mp3, etc...
*/
$productDownload = new ProductDownload();
if ($id_product_download = $productDownload->getIdFromIdProduct($this->getFieldValue($obj, 'id'))) {
$productDownload = new ProductDownload($id_product_download);
}
?>
<script type="text/javascript">
// <![CDATA[
ThickboxI18nImage = '<?php
echo $this->l('Image');
?>
';
ThickboxI18nOf = '<?php
echo $this->l('of');
?>
';;
ThickboxI18nClose = '<?php
echo $this->l('Close');
?>
';
ThickboxI18nOrEscKey = '<?php
echo $this->l('(or "Esc")');
?>
';
ThickboxI18nNext = '<?php
echo $this->l('Next >');
?>
';
ThickboxI18nPrev = '<?php
echo $this->l('< Previous');
?>
';
tb_pathToImage = '../img/loadingAnimation.gif';
//]]>
</script>
示例6: process
public function process()
{
global $cart, $currency;
parent::process();
if (!($id_product = (int) Tools::getValue('id_product')) or !Validate::isUnsignedId($id_product)) {
$this->errors[] = Tools::displayError('Product not found');
} else {
if (!Validate::isLoadedObject($this->product) or !$this->product->active and Tools::getValue('adtoken') != Tools::encrypt('PreviewProduct' . $this->product->id) || !file_exists(dirname(__FILE__) . '/../' . Tools::getValue('ad') . '/ajax.php')) {
header('HTTP/1.1 404 page not found');
$this->errors[] = Tools::displayError('Product is no longer available.');
} elseif (!$this->product->checkAccess((int) self::$cookie->id_customer)) {
$this->errors[] = Tools::displayError('You do not have access to this product.');
} else {
self::$smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int) $this->product->id));
if (!$this->product->active) {
self::$smarty->assign('adminActionDisplay', true);
}
/* rewrited url set */
$rewrited_url = self::$link->getProductLink($this->product->id, $this->product->link_rewrite);
/* Product pictures management */
require_once 'images.inc.php';
self::$smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
if (Tools::isSubmit('submitCustomizedDatas')) {
$this->pictureUpload($this->product, $cart);
$this->textRecord($this->product, $cart);
$this->formTargetFormat();
} elseif (isset($_GET['deletePicture']) and !$cart->deletePictureToProduct((int) $this->product->id, (int) Tools::getValue('deletePicture'))) {
$this->errors[] = Tools::displayError('An error occurred while deleting the selected picture');
}
$files = self::$cookie->getFamily('pictures_' . (int) $this->product->id);
$textFields = self::$cookie->getFamily('textFields_' . (int) $this->product->id);
foreach ($textFields as $key => $textField) {
$textFields[$key] = str_replace('<br />', "\n", $textField);
}
self::$smarty->assign(array('pictures' => $files, 'textFields' => $textFields));
if ((int) Tools::getValue('pp') == 1) {
echo 'here1';
}
$productPriceWithTax = Product::getPriceStatic($id_product, true, NULL, 6);
if (Product::$_taxCalculationMethod == PS_TAX_INC) {
$productPriceWithTax = Tools::ps_round($productPriceWithTax, 2);
}
if ((int) Tools::getValue('pp') == 1) {
$time2 = time();
echo 'time2: ' . $time2;
}
$productPriceWithoutEcoTax = (double) ($productPriceWithTax - $this->product->ecotax);
$configs = Configuration::getMultiple(array('PS_ORDER_OUT_OF_STOCK', 'PS_LAST_QTIES'));
/* Features / Values */
$features = $this->product->getFrontFeatures((int) self::$cookie->id_lang);
$attachments = $this->product->getAttachments((int) self::$cookie->id_lang);
/* Category */
$category = false;
if (isset($_SERVER['HTTP_REFERER']) and preg_match('!^(.*)\\/([0-9]+)\\-(.*[^\\.])|(.*)id_category=([0-9]+)(.*)$!', $_SERVER['HTTP_REFERER'], $regs) and !strstr($_SERVER['HTTP_REFERER'], '.html')) {
if (isset($regs[2]) and is_numeric($regs[2])) {
if (Product::idIsOnCategoryId((int) $this->product->id, array('0' => array('id_category' => (int) $regs[2])))) {
$category = new Category((int) $regs[2], (int) self::$cookie->id_lang);
}
} elseif (isset($regs[5]) and is_numeric($regs[5])) {
if (Product::idIsOnCategoryId((int) $this->product->id, array('0' => array('id_category' => (int) $regs[5])))) {
$category = new Category((int) $regs[5], (int) self::$cookie->id_lang);
}
}
}
if (!$category) {
$category = new Category($this->product->id_category_default, (int) self::$cookie->id_lang);
}
if (isset($category) and Validate::isLoadedObject($category)) {
self::$smarty->assign(array('path' => Tools::getPath((int) $category->id, $this->product->name, true), 'category' => $category, 'subCategories' => $category->getSubCategories((int) self::$cookie->id_lang, true), 'id_category_current' => (int) $category->id, 'id_category_parent' => (int) $category->id_parent, 'return_category_name' => Tools::safeOutput($category->name)));
} else {
self::$smarty->assign('path', Tools::getPath((int) $this->product->id_category_default, $this->product->name));
}
self::$smarty->assign('return_link', (isset($category->id) and $category->id) ? Tools::safeOutput(self::$link->getCategoryLink($category)) : 'javascript: history.back();');
$lang = Configuration::get('PS_LANG_DEFAULT');
if (Pack::isPack((int) $this->product->id, (int) $lang) and !Pack::isInStock((int) $this->product->id, (int) $lang)) {
$this->product->quantity = 0;
}
$group_reduction = (100 - Group::getReduction((int) self::$cookie->id_customer)) / 100;
$id_customer = (isset(self::$cookie->id_customer) and self::$cookie->id_customer) ? (int) self::$cookie->id_customer : 0;
$id_group = $id_customer ? (int) Customer::getDefaultGroupId($id_customer) : _PS_DEFAULT_CUSTOMER_GROUP_;
$id_country = (int) ($id_customer ? Customer::getCurrentCountry($id_customer) : Configuration::get('PS_COUNTRY_DEFAULT'));
if ((int) Tools::getValue('pp') == 1) {
$time3 = time();
echo 'time3: ' . $time3;
}
// Tax
$tax = (double) Tax::getProductTaxRate((int) $this->product->id, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
self::$smarty->assign('tax_rate', $tax);
$ecotax_rate = (double) Tax::getProductEcotaxRate($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$ecotaxTaxAmount = Tools::ps_round($this->product->ecotax, 2);
if (Product::$_taxCalculationMethod == PS_TAX_INC && (int) Configuration::get('PS_TAX')) {
$ecotaxTaxAmount = Tools::ps_round($ecotaxTaxAmount * (1 + $ecotax_rate / 100), 2);
}
$manufacturer = new Manufacturer((int) $this->product->id_manufacturer, 1);
$sizechart = new Sizechart((int) $this->product->id_sizechart, 1);
//see if the product is already in the wishlist
if ($id_customer) {
$sql = "select id from ps_wishlist where id_customer = " . $id_customer . " and id_product = " . $this->product->id;
$res = Db::getInstance()->ExecuteS($sql);
if ($res) {
//.........这里部分代码省略.........
示例7: delete
public function delete()
{
if (!GroupReduction::deleteProductReduction($this->id)) {
return false;
}
Hook::deleteProduct($this);
if (!parent::delete() or !$this->deleteCategories(true) or !$this->deleteImages() or !$this->deleteProductAttributes() or !$this->deleteProductFeatures() or !$this->deleteTags() or !$this->deleteCartProducts() or !$this->deleteAttributesImpacts() or !$this->deleteAttachments() or !$this->deleteCustomization() or !SpecificPrice::deleteByProductId((int) $this->id) or !$this->deletePack() or !$this->deleteProductSale() or !$this->deleteSceneProducts() or !$this->deleteSearchIndexes() or !$this->deleteAccessories() or !$this->deleteFromAccessories()) {
return false;
}
if ($id = ProductDownload::getIdFromIdProduct($this->id)) {
if ($productDownload = new ProductDownload($id) and !$productDownload->delete(true)) {
return false;
}
}
return true;
}
示例8: changeIdOrderState
/**
* Sets the new state of the given order
*
* @param int $new_order_state
* @param int/object $id_order
* @param bool $use_existing_payment
*/
public function changeIdOrderState($new_order_state, $id_order, $use_existing_payment = false)
{
if (!$new_order_state || !$id_order) {
return;
}
if (!is_object($id_order) && is_numeric($id_order)) {
$order = new Order((int) $id_order);
} elseif (is_object($id_order)) {
$order = $id_order;
} else {
return;
}
ShopUrl::cacheMainDomainForShop($order->id_shop);
$new_os = new OrderState((int) $new_order_state, $order->id_lang);
$old_os = $order->getCurrentOrderState();
$is_validated = $this->isValidated();
// executes hook
if (in_array($new_os->id, array(Configuration::get('PS_OS_PAYMENT'), Configuration::get('PS_OS_WS_PAYMENT')))) {
Hook::exec('actionPaymentConfirmation', array('id_order' => (int) $order->id), null, false, true, false, $order->id_shop);
}
// executes hook
Hook::exec('actionOrderStatusUpdate', array('newOrderStatus' => $new_os, 'id_order' => (int) $order->id), null, false, true, false, $order->id_shop);
if (Validate::isLoadedObject($order) && $new_os instanceof OrderState) {
// An email is sent the first time a virtual item is validated
$virtual_products = $order->getVirtualProducts();
if ($virtual_products && (!$old_os || !$old_os->logable) && $new_os && $new_os->logable) {
$context = Context::getContext();
$assign = array();
foreach ($virtual_products as $key => $virtual_product) {
$id_product_download = ProductDownload::getIdFromIdProduct($virtual_product['product_id']);
$product_download = new ProductDownload($id_product_download);
// If this virtual item has an associated file, we'll provide the link to download the file in the email
if ($product_download->display_filename != '') {
$assign[$key]['name'] = $product_download->display_filename;
$dl_link = $product_download->getTextLink(false, $virtual_product['download_hash']) . '&id_order=' . (int) $order->id . '&secure_key=' . $order->secure_key;
$assign[$key]['link'] = $dl_link;
if (isset($virtual_product['download_deadline']) && $virtual_product['download_deadline'] != '0000-00-00 00:00:00') {
$assign[$key]['deadline'] = Tools::displayDate($virtual_product['download_deadline']);
}
if ($product_download->nb_downloadable != 0) {
$assign[$key]['downloadable'] = (int) $product_download->nb_downloadable;
}
}
}
$customer = new Customer((int) $order->id_customer);
$links = '<ul>';
foreach ($assign as $product) {
$links .= '<li>';
$links .= '<a href="' . $product['link'] . '">' . Tools::htmlentitiesUTF8($product['name']) . '</a>';
if (isset($product['deadline'])) {
$links .= ' ' . Tools::htmlentitiesUTF8(Tools::displayError('expires on', false)) . ' ' . $product['deadline'];
}
if (isset($product['downloadable'])) {
$links .= ' ' . Tools::htmlentitiesUTF8(sprintf(Tools::displayError('downloadable %d time(s)', false), (int) $product['downloadable']));
}
$links .= '</li>';
}
$links .= '</ul>';
$data = array('{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{id_order}' => (int) $order->id, '{order_name}' => $order->getUniqReference(), '{nbProducts}' => count($virtual_products), '{virtualProducts}' => $links);
// If there's at least one downloadable file
if (!empty($assign)) {
Mail::Send((int) $order->id_lang, 'download_product', Mail::l('Virtual product to download', $order->id_lang), $data, $customer->email, $customer->firstname . ' ' . $customer->lastname, null, null, null, null, _PS_MAIL_DIR_, false, (int) $order->id_shop);
}
}
// @since 1.5.0 : gets the stock manager
$manager = null;
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
$manager = StockManagerFactory::getManager();
}
$errorOrCanceledStatuses = array(Configuration::get('PS_OS_ERROR'), Configuration::get('PS_OS_CANCELED'));
// foreach products of the order
if (Validate::isLoadedObject($old_os)) {
foreach ($order->getProductsDetail() as $product) {
// if becoming logable => adds sale
if ($new_os->logable && !$old_os->logable) {
ProductSale::addProductSale($product['product_id'], $product['product_quantity']);
// @since 1.5.0 - Stock Management
if (!Pack::isPack($product['product_id']) && in_array($old_os->id, $errorOrCanceledStatuses) && !StockAvailable::dependsOnStock($product['id_product'], (int) $order->id_shop)) {
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], -(int) $product['product_quantity'], $order->id_shop);
}
} elseif (!$new_os->logable && $old_os->logable) {
ProductSale::removeProductSale($product['product_id'], $product['product_quantity']);
// @since 1.5.0 - Stock Management
if (!Pack::isPack($product['product_id']) && in_array($new_os->id, $errorOrCanceledStatuses) && !StockAvailable::dependsOnStock($product['id_product'])) {
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], (int) $product['product_quantity'], $order->id_shop);
}
} elseif (!$new_os->logable && !$old_os->logable && in_array($new_os->id, $errorOrCanceledStatuses) && !in_array($old_os->id, $errorOrCanceledStatuses) && !StockAvailable::dependsOnStock($product['id_product'])) {
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], (int) $product['product_quantity'], $order->id_shop);
}
// @since 1.5.0 : if the order is being shipped and this products uses the advanced stock management :
// decrements the physical stock using $id_warehouse
if ($new_os->shipped == 1 && $old_os->shipped == 0 && Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && Warehouse::exists($product['id_warehouse']) && $manager != null && ((int) $product['advanced_stock_management'] == 1 || Pack::usesAdvancedStockManagement($product['product_id']))) {
// gets the warehouse
//.........这里部分代码省略.........
示例9: validateOrder
/**
* Validate an order in database
* Function called from a payment module
*
* @param integer $id_cart Value
* @param integer $id_order_state Value
* @param float $amountPaid Amount really paid by customer (in the default currency)
* @param string $paymentMethod Payment method (eg. 'Credit cart')
* @param string $message Message to attach to order
*/
function validateOrder($id_cart, $id_order_state, $amountPaid, $paymentMethod = 'Unknown', $message = NULL, $extraVars = array(), $currency_special = NULL, $dont_touch_amount = false)
{
global $cart;
$cart = new Cart(intval($id_cart));
// Does order already exists ?
if (Validate::isLoadedObject($cart) and $cart->OrderExists() === 0) {
// Copying data from cart
$order = new Order();
$order->id_carrier = intval($cart->id_carrier);
$order->id_customer = intval($cart->id_customer);
$order->id_address_invoice = intval($cart->id_address_invoice);
$order->id_address_delivery = intval($cart->id_address_delivery);
$vat_address = new Address(intval($order->id_address_delivery));
$id_zone = Address::getZoneById(intval($vat_address->id));
$order->id_currency = $currency_special ? intval($currency_special) : intval($cart->id_currency);
$order->id_lang = intval($cart->id_lang);
$order->id_cart = intval($cart->id);
$customer = new Customer(intval($order->id_customer));
$order->secure_key = pSQL($customer->secure_key);
$order->payment = Tools::substr($paymentMethod, 0, 32);
if (isset($this->name)) {
$order->module = $this->name;
}
$order->recyclable = $cart->recyclable;
$order->gift = intval($cart->gift);
$order->gift_message = $cart->gift_message;
$currency = new Currency($order->id_currency);
$amountPaid = !$dont_touch_amount ? Tools::ps_round(floatval($amountPaid), 2) : $amountPaid;
$order->total_paid_real = $amountPaid;
$order->total_products = floatval($cart->getOrderTotal(false, 1));
$order->total_products_wt = floatval($cart->getOrderTotal(true, 1));
$order->total_discounts = floatval(abs($cart->getOrderTotal(true, 2)));
$order->total_shipping = floatval($cart->getOrderShippingCost());
$order->total_wrapping = floatval(abs($cart->getOrderTotal(true, 6)));
$order->total_paid = floatval(Tools::ps_round(floatval($cart->getOrderTotal(true, 3)), 2));
$order->invoice_date = '0000-00-00 00:00:00';
$order->delivery_date = '0000-00-00 00:00:00';
// Amount paid by customer is not the right one -> Status = payment error
if ($order->total_paid != $order->total_paid_real) {
$id_order_state = _PS_OS_ERROR_;
}
// Creating order
if ($cart->OrderExists() === 0) {
$result = $order->add();
} else {
die(Tools::displayError('An order has already been placed using this cart'));
}
// Next !
if ($result and isset($order->id)) {
// Optional message to attach to this order
if (isset($message) and !empty($message)) {
$msg = new Message();
$message = strip_tags($message, '<br>');
if (!Validate::isCleanHtml($message)) {
$message = $this->l('Payment message is not valid, please check your module!');
}
$msg->message = $message;
$msg->id_order = intval($order->id);
$msg->private = 1;
$msg->add();
}
// Insert products from cart into order_detail table
$products = $cart->getProducts();
$productsList = '';
$db = Db::getInstance();
$query = 'INSERT INTO `' . _DB_PREFIX_ . 'order_detail`
(`id_order`, `product_id`, `product_attribute_id`, `product_name`, `product_quantity`, `product_quantity_in_stock`, `product_price`, `reduction_percent`, `reduction_amount`, `product_quantity_discount`, `product_ean13`, `product_reference`, `product_supplier_reference`, `product_weight`, `tax_name`, `tax_rate`, `ecotax`, `discount_quantity_applied`, `download_deadline`, `download_hash`)
VALUES ';
$customizedDatas = Product::getAllCustomizedDatas(intval($order->id_cart));
Product::addCustomizationPrice($products, $customizedDatas);
foreach ($products as $key => $product) {
$outOfStock = false;
$productQuantity = intval(Product::getQuantity(intval($product['id_product']), $product['id_product_attribute'] ? intval($product['id_product_attribute']) : NULL));
$quantityInStock = $productQuantity - intval($product['cart_quantity']) < 0 ? $productQuantity : intval($product['cart_quantity']);
if ($id_order_state != _PS_OS_CANCELED_ and $id_order_state != _PS_OS_ERROR_) {
if (($updateResult = Product::updateQuantity($product)) === false or $updateResult === -1) {
$outOfStock = true;
}
if (!$outOfStock) {
$product['stock_quantity'] -= $product['cart_quantity'];
}
Hook::updateQuantity($product, $order);
}
$price = Product::getPriceStatic(intval($product['id_product']), false, $product['id_product_attribute'] ? intval($product['id_product_attribute']) : NULL, 6, NULL, false, true, $product['cart_quantity'], false, intval($order->id_customer), intval($order->id_cart), intval($order->id_address_delivery));
$price_wt = Product::getPriceStatic(intval($product['id_product']), true, $product['id_product_attribute'] ? intval($product['id_product_attribute']) : NULL, 2, NULL, false, true, $product['cart_quantity'], false, intval($order->id_customer), intval($order->id_cart), intval($order->id_address_delivery));
// Add some informations for virtual products
$deadline = '0000-00-00 00:00:00';
$download_hash = NULL;
if ($id_product_download = ProductDownload::getIdFromIdProduct(intval($product['id_product']))) {
$productDownload = new ProductDownload(intval($id_product_download));
//.........这里部分代码省略.........
示例10: addWithemail
/**
* @param bool $autodate Optional
* @param array $template_vars Optional
* @param Context $context Optional
* @return bool
*/
public function addWithemail($autodate = true, $template_vars = false, Context $context = null)
{
if (!$context) {
$context = Context::getContext();
}
$order = new Order($this->id_order);
$last_order_state = $order->getCurrentOrderState();
$new_order_state = new OrderState($this->id_order_state, Configuration::get('PS_LANG_DEFAULT'));
if (!$this->add($autodate)) {
return false;
}
$result = Db::getInstance()->getRow('
SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`, os.`module_name`
FROM `' . _DB_PREFIX_ . 'order_history` oh
LEFT JOIN `' . _DB_PREFIX_ . 'orders` o ON oh.`id_order` = o.`id_order`
LEFT JOIN `' . _DB_PREFIX_ . 'customer` c ON o.`id_customer` = c.`id_customer`
LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON oh.`id_order_state` = os.`id_order_state`
LEFT JOIN `' . _DB_PREFIX_ . 'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = o.`id_lang`)
WHERE oh.`id_order_history` = ' . (int) $this->id . ' AND os.`send_email` = 1');
if (isset($result['template']) && Validate::isEmail($result['email'])) {
$topic = $result['osname'];
$data = array('{lastname}' => $result['lastname'], '{firstname}' => $result['firstname'], '{id_order}' => (int) $this->id_order, '{order_name}' => $order->getUniqReference());
if ($template_vars) {
$data = array_merge($data, $template_vars);
}
if ($result['module_name']) {
$module = Module::getInstanceByName($result['module_name']);
if (Validate::isLoadedObject($module) && isset($module->extra_mail_vars) && is_array($module->extra_mail_vars)) {
$data = array_merge($data, $module->extra_mail_vars);
}
}
$data['{total_paid}'] = Tools::displayPrice((double) $order->total_paid, new Currency((int) $order->id_currency), false);
$data['{order_name}'] = $order->getUniqReference();
// An additional email is sent the first time a virtual item is validated
$virtual_products = $order->getVirtualProducts();
if ($virtual_products && (!$last_order_state || !$last_order_state->logable) && $new_order_state && $new_order_state->logable) {
$assign = array();
foreach ($virtual_products as $key => $virtual_product) {
$id_product_download = ProductDownload::getIdFromIdProduct($virtual_product['product_id']);
$product_download = new ProductDownload($id_product_download);
// If this virtual item has an associated file, we'll provide the link to download the file in the email
if ($product_download->display_filename != '') {
$assign[$key]['name'] = $product_download->display_filename;
$dl_link = $product_download->getTextLink(false, $virtual_product['download_hash']) . '&id_order=' . $order->id . '&secure_key=' . $order->secure_key;
$assign[$key]['link'] = $dl_link;
if ($virtual_product['download_deadline'] != '0000-00-00 00:00:00') {
$assign[$key]['deadline'] = Tools::displayDate($virtual_product['download_deadline'], $order->id_lang);
}
if ($product_download->nb_downloadable != 0) {
$assign[$key]['downloadable'] = $product_download->nb_downloadable;
}
}
}
$context->smarty->assign('virtualProducts', $assign);
$context->smarty->assign('id_order', $order->id);
$iso = Language::getIsoById((int) $order->id_lang);
$links = $context->smarty->fetch(_PS_MAIL_DIR_ . $iso . '/download-product.tpl');
$tmp_array = array('{nbProducts}' => count($virtual_products), '{virtualProducts}' => $links);
$data = array_merge($data, $tmp_array);
// If there's at least one downloadable file
if (!empty($assign)) {
Mail::Send((int) $order->id_lang, 'download_product', Mail::l('Virtual product to download', $order->id_lang), $data, $result['email'], $result['firstname'] . ' ' . $result['lastname'], null, null, null, null, _PS_MAIL_DIR_, false, (int) $order->id_shop);
}
}
if (Validate::isLoadedObject($order)) {
Mail::Send((int) $order->id_lang, $result['template'], $topic, $data, $result['email'], $result['firstname'] . ' ' . $result['lastname'], null, null, null, null, _PS_MAIL_DIR_, false, (int) $order->id_shop);
}
}
return true;
}
示例11: updateDownloadProduct
public function updateDownloadProduct($product, $edit = 0)
{
$bqhdst = "is_virtual_file";
${$bqhdst} = (int) Tools::getValue("is_virtual_file");
if (Tools::getValue("is_virtual_good") == "true") {
if (Tools::getValue("virtual_product_expiration_date") && !Validate::isDate(Tools::getValue("virtual_product_expiration_date") && !empty(${${"GLOBALS"}["ofnqhqwloxy"]}))) {
if (!Tools::getValue("virtual_product_expiration_date")) {
$this->errors[] = Tools::displayError("This field expiration date attribute is required.");
return false;
}
}
${"GLOBALS"}["sawwdmhhhf"] = "is_shareable";
$pvfvdbstogj = "download";
if (${${"GLOBALS"}["pjupudkhthj"]} == 1) {
${${"GLOBALS"}["oketuohcmb"]} = (int) ProductDownload::getIdFromIdProduct((int) $product->id);
$yduygdht = "id_product_download";
if (!${${"GLOBALS"}["oketuohcmb"]}) {
${$yduygdht} = (int) Tools::getValue("virtual_product_id");
}
} else {
${${"GLOBALS"}["oketuohcmb"]} = Tools::getValue("virtual_product_id");
}
$mpudnceviio = "virtual_product_expiration_date";
$njckiqo = "filename";
${"GLOBALS"}["kvmjgmdvfpxk"] = "virtual_product_expiration_date";
${${"GLOBALS"}["sawwdmhhhf"]} = Tools::getValue("virtual_product_is_shareable");
${"GLOBALS"}["qgipvncl"] = "virtual_product_filename";
${${"GLOBALS"}["dfdmmppxadnp"]} = Tools::getValue("virtual_product_name");
${${"GLOBALS"}["qgipvncl"]} = Tools::getValue("virtual_product_filename");
${${"GLOBALS"}["xpylkyaysxls"]} = Tools::getValue("virtual_product_nb_days");
$dtltqsd = "virtual_product_filename";
$cbycann = "virtual_product_filename";
${${"GLOBALS"}["ebothfnmt"]} = Tools::getValue("virtual_product_nb_downloable");
${${"GLOBALS"}["bktmulsvfp"]} = Tools::getValue("virtual_product_expiration_date");
if (${$cbycann}) {
${${"GLOBALS"}["letornu"]} = ${$dtltqsd};
} else {
${${"GLOBALS"}["letornu"]} = ProductDownload::getNewFilename();
}
${$pvfvdbstogj} = new ProductDownload((int) ${${"GLOBALS"}["oketuohcmb"]});
$download->id_product = (int) $product->id;
$download->display_filename = ${${"GLOBALS"}["dfdmmppxadnp"]};
$download->filename = ${$njckiqo};
$download->date_add = date("Y-m-d H:i:s");
$vcyhlrvrm = "is_shareable";
$download->date_expiration = ${${"GLOBALS"}["kvmjgmdvfpxk"]} ? ${$mpudnceviio} . " 23:59:59" : "";
$download->nb_days_accessible = (int) ${${"GLOBALS"}["xpylkyaysxls"]};
$download->nb_downloadable = (int) ${${"GLOBALS"}["ebothfnmt"]};
$download->active = 1;
$download->is_shareable = (int) ${$vcyhlrvrm};
if ($download->save()) {
return true;
}
} else {
${"GLOBALS"}["eycluxdax"] = "id_product_download";
${"GLOBALS"}["ikiqrzgois"] = "edit";
if (${${"GLOBALS"}["ikiqrzgois"]} == 1) {
$kmioedds = "id_product_download";
${$kmioedds} = (int) ProductDownload::getIdFromIdProduct((int) $product->id);
if (!${${"GLOBALS"}["oketuohcmb"]}) {
${${"GLOBALS"}["oketuohcmb"]} = (int) Tools::getValue("virtual_product_id");
}
} else {
${${"GLOBALS"}["eycluxdax"]} = ProductDownload::getIdFromIdProduct($product->id);
}
if (!empty(${${"GLOBALS"}["oketuohcmb"]})) {
$ykdgublwd = "product_download";
${$ykdgublwd} = new ProductDownload((int) ${${"GLOBALS"}["oketuohcmb"]});
$product_download->date_expiration = date("Y-m-d H:i:s", time() - 1);
$product_download->active = 0;
return $product_download->save();
}
}
return false;
}
示例12: addWithemail
public function addWithemail($autodate = true, $templateVars = false)
{
$lastOrderState = $this->getLastOrderState($this->id_order);
if (!parent::add($autodate)) {
return false;
}
$result = Db::getInstance()->getRow('
SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` osname, c.`email`
FROM `' . _DB_PREFIX_ . 'order_history` oh
LEFT JOIN `' . _DB_PREFIX_ . 'orders` o ON oh.`id_order` = o.`id_order`
LEFT JOIN `' . _DB_PREFIX_ . 'customer` c ON o.`id_customer` = c.`id_customer`
LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON oh.`id_order_state` = os.`id_order_state`
LEFT JOIN `' . _DB_PREFIX_ . 'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = o.`id_lang`)
WHERE oh.`id_order_history` = ' . (int) $this->id . ' AND os.`send_email` = 1');
if (isset($result['template']) and Validate::isEmail($result['email'])) {
$topic = $result['osname'];
$data = array('{lastname}' => $result['lastname'], '{firstname}' => $result['firstname'], '{id_order}' => (int) $this->id_order);
if ($templateVars) {
$data = array_merge($data, $templateVars);
}
$order = new Order((int) $this->id_order);
$data['{total_paid}'] = Tools::displayPrice((double) $order->total_paid, new Currency((int) $order->id_currency), false);
$data['{order_name}'] = sprintf("#%06d", (int) $order->id);
// An additional email is sent the first time a virtual item is validated
if (($virtualProducts = $order->getVirtualProducts()) && (!$lastOrderState || !$lastOrderState->logable) && ($newOrderState = new OrderState($this->id_order_state, _PS_LANG_DEFAULT_)) && $newOrderState->logable) {
global $smarty;
$assign = array();
foreach ($virtualProducts as $key => $virtualProduct) {
$id_product_download = ProductDownload::getIdFromIdProduct($virtualProduct['product_id']);
$product_download = new ProductDownload($id_product_download);
$assign[$key]['name'] = $product_download->display_filename;
$dl_link = $product_download->getTextLink(false, $virtualProduct['download_hash']) . '&id_order=' . $order->id . '&secure_key=' . $order->secure_key;
$assign[$key]['link'] = $dl_link;
if ($virtualProduct['download_deadline'] != '0000-00-00 00:00:00') {
$assign[$key]['deadline'] = Tools::displayDate($virtualProduct['download_deadline'], $order->id_lang);
}
if ($product_download->nb_downloadable != 0) {
$assign[$key]['downloadable'] = $product_download->nb_downloadable;
}
}
$smarty->assign('virtualProducts', $assign);
$smarty->assign('id_order', $order->id);
$smarty->assign('order_name', $data['{order_name}']);
$iso = Language::getIsoById((int) $order->id_lang);
$links = $smarty->fetch(_PS_MAIL_DIR_ . $iso . '/download-product.tpl');
$tmpArray = array('{nbProducts}' => count($virtualProducts), '{virtualProducts}' => $links);
$data = array_merge($data, $tmpArray);
Mail::Send((int) $order->id_lang, 'download_product', Mail::l('Virtual product to download', (int) $order->id_lang), $data, $result['email'], $result['firstname'] . ' ' . $result['lastname']);
}
if (Validate::isLoadedObject($order)) {
Mail::Send((int) $order->id_lang, $result['template'], $topic, $data, $result['email'], $result['firstname'] . ' ' . $result['lastname']);
}
}
return true;
}
示例13: validateOrder
//.........这里部分代码省略.........
$id_state = 0;
$id_county = 0;
$rate = 0;
$id_address = $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')};
$address_infos = Address::getCountryAndState($id_address);
if ($address_infos['id_country']) {
$id_country = (int) $address_infos['id_country'];
$id_state = (int) $address_infos['id_state'];
$id_county = (int) County::getIdCountyByZipCode($address_infos['id_state'], $address_infos['postcode']);
}
$allTaxes = TaxRulesGroup::getTaxes((int) Product::getIdTaxRulesGroupByIdProduct((int) $product['id_product']), $id_country, $id_state, $id_county);
// If its a freeOrder, there will be no calculation
if ($order->total_products > 0) {
// remove order discount quotepart on product price in order to obtain the real tax
$ratio = $price / $order->total_products;
$order_reduction_amount = (double) abs($cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS)) * $ratio;
$tmp_price = $price - $order_reduction_amount;
foreach ($allTaxes as $res) {
if (!isset($store_all_taxes[$res->id])) {
$store_all_taxes[$res->id] = array();
$store_all_taxes[$res->id]['amount'] = 0;
}
$store_all_taxes[$res->id]['name'] = $res->name[(int) $order->id_lang];
$store_all_taxes[$res->id]['rate'] = $res->rate;
$unit_tax_amount = $tmp_price * ($res->rate * 0.01);
$tmp_price = $tmp_price + $unit_tax_amount;
$store_all_taxes[$res->id]['amount'] += $unit_tax_amount * $product['cart_quantity'];
}
}
/* End */
// Add some informations for virtual products
$deadline = '0000-00-00 00:00:00';
$download_hash = null;
if ($id_product_download = ProductDownload::getIdFromIdProduct((int) $product['id_product'])) {
$productDownload = new ProductDownload((int) $id_product_download);
$deadline = $productDownload->getDeadLine();
$download_hash = $productDownload->getHash();
}
// Exclude VAT
if (!_PS_TAX_) {
$product['tax'] = 0;
$product['rate'] = 0;
$tax_rate = 0;
} else {
$tax_rate = Tax::getProductTaxRate((int) $product['id_product'], $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
}
$ecotaxTaxRate = 0;
if (!empty($product['ecotax'])) {
$ecotaxTaxRate = Tax::getProductEcotaxRate($order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
}
$product_price = (double) Product::getPriceStatic((int) $product['id_product'], false, $product['id_product_attribute'] ? (int) $product['id_product_attribute'] : NULL, Product::getTaxCalculationMethod((int) $order->id_customer) == PS_TAX_EXC ? 2 : 6, NULL, false, false, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $specificPrice, false, false);
$group_reduction = (double) GroupReduction::getValueForProduct((int) $product['id_product'], $customer->id_default_group) * 100;
if (!$group_reduction) {
$group_reduction = (double) Group::getReduction((int) $order->id_customer);
}
$quantityDiscount = SpecificPrice::getQuantityDiscount((int) $product['id_product'], Shop::getCurrentShop(), (int) $cart->id_currency, (int) $vat_address->id_country, (int) $customer->id_default_group, (int) $product['cart_quantity']);
$unitPrice = Product::getPriceStatic((int) $product['id_product'], true, $product['id_product_attribute'] ? intval($product['id_product_attribute']) : NULL, 2, NULL, false, true, 1, false, (int) $order->id_customer, NULL, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$quantityDiscountValue = $quantityDiscount ? (Product::getTaxCalculationMethod((int) $order->id_customer) == PS_TAX_EXC ? Tools::ps_round($unitPrice, 2) : $unitPrice) - $quantityDiscount['price'] * (1 + $tax_rate / 100) : 0.0;
$query .= '(' . (int) $order->id . ',
' . (int) $product['id_product'] . ',
' . (isset($product['id_product_attribute']) ? (int) $product['id_product_attribute'] : 'NULL') . ',
\'' . pSQL($product['name'] . ((isset($product['attributes']) and $product['attributes'] != NULL) ? ' - ' . $product['attributes'] : '')) . '\',
' . (int) $product['cart_quantity'] . ',
' . $quantityInStock . ',
' . $product_price . ',
' . (double) (($specificPrice and $specificPrice['reduction_type'] == 'percentage') ? $specificPrice['reduction'] * 100 : 0.0) . ',
示例14: hasDownload
/**
* Check if cart has product download
*
* @param object $cart
* @return boolean
*/
private function hasDownload($cart)
{
if (!is_object($cart)) {
return false;
}
if (!method_exists($cart, 'getProducts')) {
return false;
}
$has = false;
foreach ($cart->getProducts() as $product) {
$pd = ProductDownload::getIdFromIdProduct((int) $product['id_product']);
if ($pd and Validate::isUnsignedInt($pd)) {
$has = true;
}
}
return $has;
}
示例15: initContent
/**
* Assign template vars related to page content
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
if (!$this->errors) {
if (Pack::isPack((int) $this->product->id) && !Pack::isInStock((int) $this->product->id)) {
$this->product->quantity = 0;
}
$this->product->description = $this->transformDescriptionWithImg($this->product->description);
// Assign to the template the id of the virtual product. "0" if the product is not downloadable.
$this->context->smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int) $this->product->id));
$this->context->smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
if (Tools::isSubmit('submitCustomizedDatas')) {
// If cart has not been saved, we need to do it so that customization fields can have an id_cart
// We check that the cookie exists first to avoid ghost carts
if (!$this->context->cart->id && isset($_COOKIE[$this->context->cookie->getName()])) {
$this->context->cart->add();
$this->context->cookie->id_cart = (int) $this->context->cart->id;
}
$this->pictureUpload();
$this->textRecord();
$this->formTargetFormat();
} elseif (Tools::getIsset('deletePicture') && !$this->context->cart->deleteCustomizationToProduct($this->product->id, Tools::getValue('deletePicture'))) {
$this->errors[] = Tools::displayError('An error occurred while deleting the selected picture.');
}
$pictures = array();
$text_fields = array();
if ($this->product->customizable) {
$files = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_FILE, true);
foreach ($files as $file) {
$pictures['pictures_' . $this->product->id . '_' . $file['index']] = $file['value'];
}
$texts = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_TEXTFIELD, true);
foreach ($texts as $text_field) {
$text_fields['textFields_' . $this->product->id . '_' . $text_field['index']] = str_replace('<br />', "\n", $text_field['value']);
}
}
$this->context->smarty->assign(array('pictures' => $pictures, 'textFields' => $text_fields));
$this->product->customization_required = false;
$customization_fields = $this->product->customizable ? $this->product->getCustomizationFields($this->context->language->id) : false;
if (is_array($customization_fields)) {
foreach ($customization_fields as $customization_field) {
if ($this->product->customization_required = $customization_field['required']) {
break;
}
}
}
// Assign template vars related to the category + execute hooks related to the category
$this->assignCategory();
// Assign template vars related to the price and tax
$this->assignPriceAndTax();
// Assign template vars related to the images
$this->assignImages();
// Assign attribute groups to the template
$this->assignAttributesGroups();
// Assign attributes combinations to the template
$this->assignAttributesCombinations();
// Pack management
$pack_items = Pack::isPack($this->product->id) ? Pack::getItemTable($this->product->id, $this->context->language->id, true) : array();
$this->context->smarty->assign('packItems', $pack_items);
$this->context->smarty->assign('packs', Pack::getPacksTable($this->product->id, $this->context->language->id, true, 1));
if (isset($this->category->id) && $this->category->id) {
$return_link = Tools::safeOutput($this->context->link->getCategoryLink($this->category));
} else {
$return_link = 'javascript: history.back();';
}
$accessories = $this->product->getAccessories($this->context->language->id);
if ($this->product->cache_is_pack || count($accessories)) {
$this->context->controller->addCSS(_THEME_CSS_DIR_ . 'product_list.css');
}
if ($this->product->customizable) {
$customization_datas = $this->context->cart->getProductCustomization($this->product->id, null, true);
}
// by webkul
$htl_features = array();
$obj_hotel_room_type = new HotelRoomType();
$room_info_by_product_id = $obj_hotel_room_type->getRoomTypeInfoByIdProduct($this->product->id);
$hotel_id = $room_info_by_product_id['id_hotel'];
if (isset($hotel_id) && $hotel_id) {
$obj_hotel_branch = new HotelBranchInformation();
$hotel_info_by_id = $obj_hotel_branch->hotelBranchInfoById($hotel_id);
$hotel_policies = $hotel_info_by_id['policies'];
$hotel_name = $hotel_info_by_id['hotel_name'];
$country = Country::getNameById($this->context->language->id, $hotel_info_by_id['country_id']);
$state = State::getNameById($hotel_info_by_id['state_id']);
$hotel_location = $hotel_info_by_id['city'] . ', ' . $state . ', ' . $country;
$obj_hotel_feaures_ids = $obj_hotel_branch->getFeaturesOfHotelByHotelId($hotel_id);
if (isset($obj_hotel_feaures_ids) && $obj_hotel_feaures_ids) {
foreach ($obj_hotel_feaures_ids as $key => $value) {
$obj_htl_ftr = new HotelFeatures();
$htl_info = $obj_htl_ftr->getFeatureInfoById($value['feature_id']);
$htl_features[] = $htl_info['name'];
}
}
}
$date_from = Tools::getValue('date_from');
$date_to = Tools::getValue('date_to');
//.........这里部分代码省略.........