本文整理汇总了PHP中ProductDownload类的典型用法代码示例。如果您正苦于以下问题:PHP ProductDownload类的具体用法?PHP ProductDownload怎么用?PHP ProductDownload使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ProductDownload类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: attach_download
/**
* Attaches a product download asset to the price object
*
* @since 1.1
*
* @return boolean
**/
function attach_download ($id) {
if (!$id) return false;
$Download = new ProductDownload($id);
$Download->parent = $this->id;
$Download->save();
do_action('attach_product_download',$id,$this->id);
return true;
}
示例2: 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;
}
示例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((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');
}
示例4: 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');
}
示例5: 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;
}
示例6: hookPayment
/**
* @param $params
* @return bool
*/
public function hookPayment($params)
{
if (!$this->active) {
return;
}
global $smarty;
// Check if cart has product download
$i = 0;
$products = $params['cart']->getProducts();
$total = count($products);
foreach ($products as $key => $product) {
$pd = ProductDownload::getIdFromIdProduct((int) $product['id_product']);
if ($pd and Validate::isUnsignedInt($pd)) {
$i++;
}
}
if ($i && $total == $i) {
return false;
}
$cart_total_paid = (double) Tools::ps_round((double) $this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
$cod_fee = $cart_total_paid <= Configuration::get('COD_MINIMUM_AMOUNT') ? (double) Configuration::get('COD_FEE') : 0;
$smarty->assign(array('this_path' => $this->_path, 'this_path_cod' => $this->_path, 'this_cod_fee' => $cod_fee, 'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->name . '/'));
return $this->display(__FILE__, 'payment.tpl');
}
示例7: containsVirtualProducts
public function containsVirtualProducts()
{
/*
* EU-Legal
* is at least one virtual product in cart?
*/
if (!ProductDownload::isFeatureActive()) {
return false;
}
if (!isset(self::$_isPartlyVirtualCart[$this->id])) {
$products = $this->getProducts();
if (!count($products)) {
return false;
}
$is_partly_virtual = 0;
foreach ($products as $product) {
if ($product['is_virtual']) {
$is_partly_virtual = 1;
}
}
self::$_isPartlyVirtualCart[$this->id] = (int) $is_partly_virtual;
}
return self::$_isPartlyVirtualCart[$this->id];
}
示例8: displayFormInformations
//.........这里部分代码省略.........
<td style="padding-bottom:5px;">
<select name="id_manufacturer" id="id_manufacturer">
<option value="0">-- ' . $this->l('Choose (optional)') . ' --</option>';
if ($id_manufacturer = $this->getFieldValue($obj, 'id_manufacturer')) {
echo ' <option value="' . $id_manufacturer . '" selected="selected">' . Manufacturer::getNameById($id_manufacturer) . '</option>
<option disabled="disabled">----------</option>';
}
echo '
</select> <a href="?tab=AdminManufacturers&addmanufacturer&token=' . Tools::getAdminToken('AdminManufacturers' . (int) Tab::getIdFromClassName('AdminManufacturers') . (int) $cookie->id_employee) . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete product information entered?', __CLASS__, true, false) . '\');"><img src="../img/admin/add.gif" alt="' . $this->l('Create') . '" title="' . $this->l('Create') . '" /> <b>' . $this->l('Create') . '</b></a>
</td>
</tr>
<tr>
<td style="vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $this->l('Supplier:') . '</td>
<td style="padding-bottom:5px;">
<select name="id_supplier" id="id_supplier">
<option value="0">-- ' . $this->l('Choose (optional)') . ' --</option>';
if ($id_supplier = $this->getFieldValue($obj, 'id_supplier')) {
echo ' <option value="' . $id_supplier . '" selected="selected">' . Supplier::getNameById($id_supplier) . '</option>
<option disabled="disabled">----------</option>';
}
echo '
</select> <a href="?tab=AdminSuppliers&addsupplier&token=' . Tools::getAdminToken('AdminSuppliers' . (int) Tab::getIdFromClassName('AdminSuppliers') . (int) $cookie->id_employee) . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false) . '\');"><img src="../img/admin/add.gif" alt="' . $this->l('Create') . '" title="' . $this->l('Create') . '" /> <b>' . $this->l('Create') . '</b></a>
</td>
</tr>
</table>
<div class="clear"></div>
<table cellpadding="5" style="width: 100%;">
<tr><td colspan="2"><hr style="width:100%;" /></td></tr>';
$this->displayPack($obj);
echo ' <tr><td colspan="2"><hr style="width:100%;" /></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';
//]]>
示例9: init
public function init()
{
if (isset($this->context->employee) && $this->context->employee->isLoggedBack() && Tools::getValue('file')) {
// Admin can directly access to file
$filename = Tools::getValue('file');
if (!Validate::isSha1($filename)) {
die(Tools::displayError());
}
$file = _PS_DOWNLOAD_DIR_ . strval(preg_replace('/\\.{2,}/', '.', $filename));
$filename = ProductDownload::getFilenameFromFilename(Tools::getValue('file'));
if (empty($filename)) {
$newFileName = Tools::getValue('filename');
if (!empty($newFileName)) {
$filename = Tools::getValue('filename');
} else {
$filename = 'file';
}
}
if (!file_exists($file)) {
Tools::redirect('index.php');
}
} else {
if (!($key = Tools::getValue('key'))) {
$this->displayCustomError('Invalid key.');
}
Tools::setCookieLanguage();
if (!$this->context->customer->isLogged() && !Tools::getValue('secure_key') && !Tools::getValue('id_order')) {
Tools::redirect('index.php?controller=authentication&back=get-file.php&key=' . $key);
} else {
if (!$this->context->customer->isLogged() && Tools::getValue('secure_key') && Tools::getValue('id_order')) {
$order = new Order((int) Tools::getValue('id_order'));
if (!Validate::isLoadedObject($order)) {
$this->displayCustomError('Invalid key.');
}
if ($order->secure_key != Tools::getValue('secure_key')) {
$this->displayCustomError('Invalid key.');
}
}
}
/* Key format: <sha1-filename>-<hashOrder> */
$tmp = explode('-', $key);
if (count($tmp) != 2) {
$this->displayCustomError('Invalid key.');
}
$filename = $tmp[0];
$hash = $tmp[1];
if (!($info = OrderDetail::getDownloadFromHash($hash))) {
$this->displayCustomError('This product does not exist in our store.');
}
/* Product no more present in catalog */
if (!isset($info['id_product_download']) || empty($info['id_product_download'])) {
$this->displayCustomError('This product has been deleted.');
}
if (!file_exists(_PS_DOWNLOAD_DIR_ . $filename)) {
$this->displayCustomError('This file no longer exists.');
}
if (isset($info['product_quantity_refunded']) && isset($info['product_quantity_return']) && ($info['product_quantity_refunded'] > 0 || $info['product_quantity_return'] > 0)) {
$this->displayCustomError('This product has been refunded.');
}
$now = time();
$product_deadline = strtotime($info['download_deadline']);
if ($now > $product_deadline && $info['download_deadline'] != '0000-00-00 00:00:00') {
$this->displayCustomError('The product deadline is in the past.');
}
$customer_deadline = strtotime($info['date_expiration']);
if ($now > $customer_deadline && $info['date_expiration'] != '0000-00-00 00:00:00') {
$this->displayCustomError('Expiration date has passed, you cannot download this product');
}
if ($info['download_nb'] >= $info['nb_downloadable'] && $info['nb_downloadable']) {
$this->displayCustomError('You have reached the maximum number of allowed downloads.');
}
/* Access is authorized -> increment download value for the customer */
OrderDetail::incrementDownload($info['id_order_detail']);
$file = _PS_DOWNLOAD_DIR_ . $info['filename'];
$filename = $info['display_filename'];
}
/* Detect mime content type */
$mimeType = false;
if (function_exists('finfo_open')) {
$finfo = @finfo_open(FILEINFO_MIME);
$mimeType = @finfo_file($finfo, $file);
@finfo_close($finfo);
} else {
if (function_exists('mime_content_type')) {
$mimeType = @mime_content_type($file);
} else {
if (function_exists('exec')) {
$mimeType = trim(@exec('file -b --mime-type ' . escapeshellarg($file)));
if (!$mimeType) {
$mimeType = trim(@exec('file --mime ' . escapeshellarg($file)));
}
if (!$mimeType) {
$mimeType = trim(@exec('file -bi ' . escapeshellarg($file)));
}
}
}
}
if (empty($mimeType)) {
$bName = basename($filename);
$bName = explode('.', $bName);
//.........这里部分代码省略.........
示例10: 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) {
//.........这里部分代码省略.........
示例11: array
global $errors;
// Modules might throw errors into postProcess
if (!isset($errors)) {
$errors = array();
}
if (!($id_product = intval(Tools::getValue('id_product'))) or !Validate::isUnsignedId($id_product)) {
$errors[] = Tools::displayError('product not found');
} else {
$product = new Product($id_product, true, intval($cookie->id_lang));
if (!Validate::isLoadedObject($product) or !$product->active) {
header('HTTP/1.1 404 page not found');
$errors[] = Tools::displayError('product is no longer available');
} elseif (!$product->checkAccess(intval($cookie->id_customer))) {
$errors[] = Tools::displayError('you do not have access to this product');
} else {
$smarty->assign('virtual', ProductDownload::getIdFromIdProduct(intval($product->id)));
/* rewrited url set */
$rewrited_url = $link->getProductLink($product->id, $product->link_rewrite);
/* Product pictures management */
require_once 'images.inc.php';
$smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
if (Tools::isSubmit('submitCustomizedDatas')) {
pictureUpload($product, $cart);
textRecord($product, $cart);
formTargetFormat();
} elseif (isset($_GET['deletePicture']) and !$cart->deletePictureToProduct(intval($product->id), intval(Tools::getValue('deletePicture')))) {
$errors[] = Tools::displayError('An error occured while deleting the selected picture');
}
$files = $cookie->getFamily('pictures_' . intval($product->id));
$textFields = $cookie->getFamily('textFields_' . intval($product->id));
$smarty->assign(array('pictures' => $files, 'textFields' => $textFields));
示例12: process
public function process()
{
global $cart, $currency;
parent::process();
if (!Validate::isLoadedObject($this->product)) {
$this->errors[] = Tools::displayError('Product not found');
} else {
if (!$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);
}
/* Product pictures management */
require_once 'images.inc.php';
if ($this->product->customizable) {
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));
}
/* Features / Values */
$features = $this->product->getFrontFeatures((int) self::$cookie->id_lang);
$attachments = $this->product->cache_has_attachments ? $this->product->getAttachments((int) self::$cookie->id_lang) : array();
/* 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();');
if (Pack::isPack((int) $this->product->id) and !Pack::isInStock((int) $this->product->id)) {
$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'));
// Tax
$tax = (double) Tax::getProductTaxRate((int) $this->product->id, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
self::$smarty->assign('tax_rate', $tax);
$productPriceWithTax = Product::getPriceStatic($this->product->id, true, NULL, 6);
if (Product::$_taxCalculationMethod == PS_TAX_INC) {
$productPriceWithTax = Tools::ps_round($productPriceWithTax, 2);
}
$productPriceWithoutEcoTax = (double) ($productPriceWithTax - $this->product->ecotax);
$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);
}
self::$smarty->assign(array('quantity_discounts' => $this->formatQuantityDiscounts(SpecificPrice::getQuantityDiscounts((int) $this->product->id, (int) Shop::getCurrentShop(), (int) self::$cookie->id_currency, $id_country, $id_group), $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false), (double) $tax), 'product' => $this->product, 'ecotax_tax_inc' => $ecotaxTaxAmount, 'ecotax_tax_exc' => Tools::ps_round($this->product->ecotax, 2), 'ecotaxTax_rate' => $ecotax_rate, 'homeSize' => Image::getSize('home'), 'product_manufacturer' => new Manufacturer((int) $this->product->id_manufacturer, self::$cookie->id_lang), 'token' => Tools::getToken(false), 'productPriceWithoutEcoTax' => (double) $productPriceWithoutEcoTax, 'features' => $features, 'attachments' => $attachments, 'allow_oosp' => $this->product->isAvailableWhenOutOfStock((int) $this->product->out_of_stock), 'last_qties' => (int) Configuration::get('PS_LAST_QTIES'), 'group_reduction' => $group_reduction, 'col_img_dir' => _PS_COL_IMG_DIR_));
self::$smarty->assign(array('HOOK_EXTRA_LEFT' => Module::hookExec('extraLeft'), 'HOOK_EXTRA_RIGHT' => Module::hookExec('extraRight'), 'HOOK_PRODUCT_OOS' => Hook::productOutOfStock($this->product), 'HOOK_PRODUCT_FOOTER' => Hook::productFooter($this->product, $category), 'HOOK_PRODUCT_ACTIONS' => Module::hookExec('productActions'), 'HOOK_PRODUCT_TAB' => Module::hookExec('productTab'), 'HOOK_PRODUCT_TAB_CONTENT' => Module::hookExec('productTabContent')));
$images = $this->product->getImages((int) self::$cookie->id_lang);
$productImages = array();
foreach ($images as $k => $image) {
if ($image['cover']) {
self::$smarty->assign('mainImage', $images[0]);
$cover = $image;
$cover['id_image'] = Configuration::get('PS_LEGACY_IMAGES') ? $this->product->id . '-' . $image['id_image'] : $image['id_image'];
$cover['id_image_only'] = (int) $image['id_image'];
}
$productImages[(int) $image['id_image']] = $image;
}
if (!isset($cover)) {
$cover = array('id_image' => Language::getIsoById(self::$cookie->id_lang) . '-default', 'legend' => 'No picture', 'title' => 'No picture');
}
$size = Image::getSize('large');
self::$smarty->assign(array('cover' => $cover, 'imgWidth' => (int) $size['width'], 'mediumSize' => Image::getSize('medium'), 'largeSize' => Image::getSize('large'), 'accessories' => $this->product->getAccessories((int) self::$cookie->id_lang)));
if (count($productImages)) {
self::$smarty->assign('images', $productImages);
//.........这里部分代码省略.........
示例13: shopp_rmv_product_download
/**
* shopp_rmv_product_download
*
* Remove a product download asset
*
* @api
* @since 1.2
*
* @param int $download the product asset id
* @return bool true on success, false on failure
**/
function shopp_rmv_product_download($download)
{
if (empty($download)) {
shopp_debug(__FUNCTION__ . ' failed: download parameter required.');
return false;
}
$File = new ProductDownload($download);
if (empty($File->id)) {
shopp_debug(__FUNCTION__ . " failed: No such product download with id {$download}.");
return false;
}
return $File->delete();
}
示例14: initContent
/**
* Assign template vars related to page content
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
if (!$this->errors) {
$webservice_exi = new SoapClient('http://www2.promoshop.com.mx/ws_store/service.asmx?WSDL');
$parameter = array("ItemNumber" => $this->product->item_number, "key" => EXIMAGEN_KEY);
$inventory = $webservice_exi->GetInventory($parameter);
if (isset($inventory->GetInventoryResult->InventoryData->SKU)) {
$inventory = $inventory->GetInventoryResult;
} else {
$inventory = $inventory->GetInventoryResult->InventoryData;
}
$quote_table = "";
$decoration_list = '';
$decoration = json_decode($this->product->decoration_details);
if (!isset($decoration->areasimp->ItemNumber)) {
$decoration = $decoration->areasimp;
}
foreach ($decoration as $deco) {
$decoration_list .= $deco->TecnicaFull . ', ';
}
$decoration_list = substr($decoration_list, 0, -2);
if ($this->product->quick_quote != '') {
$quote = json_decode($this->product->quick_quote);
//var_dump($this->product->quick_quote);
foreach ($quote->PricesArray->Prices as $price) {
$quote_table .= "<tr><td>" . $price->Piezas;
$precio = explode('.', $price->Precio);
$precio_imp = explode('.', $price->PrecioImp);
if (intval($price->Piezas) < 10) {
$quote_table .= " Muestra";
} else {
$quote_table .= " Piezas";
}
$quote_table .= "</td>";
$quote_table .= "<td>\$" . $precio[0] . "." . substr($precio[1], 0, 2) . "</td>";
$quote_table .= "<td>\$" . $precio_imp[0] . "." . substr($precio_imp[1], 0, 2) . "</td></tr>";
}
}
$link = new Link();
$productUrl = $link->getProductLink($this->product);
$margin = Configuration::get('PROFIT_MARGIN');
$price_type = Configuration::get('PRODUCT_DYNAMIC_PRICE');
if (isset($margin) && $price_type == 1) {
$margin = floatval($margin) / 100;
$margin = 1 - $margin;
$this->product->base_price = $this->product->base_price / $margin;
}
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();
} else {
if (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;
$customizationFields = $this->product->customizable ? $this->product->getCustomizationFields($this->context->language->id) : false;
if (is_array($customizationFields)) {
foreach ($customizationFields as $customizationField) {
if ($this->product->customization_required = $customizationField['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();
//.........这里部分代码省略.........
示例15: isVirtualCart
/**
* Check if cart contains only virtual products
* @return boolean true if is a virtual cart or false
*
*/
public function isVirtualCart()
{
if (!intval(self::getNbProducts($this->id))) {
return false;
}
$allVirtual = true;
foreach ($this->getProducts() as $product) {
$allVirtual &= ProductDownload::getIdFromIdProduct(intval($product['id_product'])) ? true : false;
}
return $allVirtual;
}