本文整理汇总了PHP中Image::getExistingImgPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::getExistingImgPath方法的具体用法?PHP Image::getExistingImgPath怎么用?PHP Image::getExistingImgPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image
的用法示例。
在下文中一共展示了Image::getExistingImgPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getImageLink
/**
* 取得一张图片的HTTP访问链接
*
* @param $id_image
* @param $type
* @return bool|string
*/
public static function getImageLink($id_image, $type = "")
{
if (!$id_image) {
return false;
}
$image = new Image((int) $id_image);
if ($image->getExistingImgPath()) {
if (empty($type)) {
return _TM_PRO_URL . $image->getExistingImgPath() . '.jpg';
}
return _TM_PRO_URL . $image->getExistingImgPath() . '-' . $type . '.jpg';
}
}
示例2: reloadImages
public function reloadImages()
{
$dir = _TM_PRO_IMG_DIR;
$productsImages = Image::getAllImages();
foreach ($productsImages as $k => $image) {
$imageObj = new Image($image['id_image']);
//echo $dir.$imageObj->getExistingImgPath().'.jpg';
if (file_exists($dir . $imageObj->getExistingImgPath() . '.jpg')) {
if (!ImageCore::imageResize($dir . $imageObj->getExistingImgPath() . '.jpg', $dir . $imageObj->getExistingImgPath() . '-' . stripslashes($this->name) . '.jpg', (int) $this->width, (int) $this->height)) {
$errors = true;
}
}
}
}
示例3: displayForm
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
parent::displayForm();
$imagesTypes = ImageType::getImagesTypes();
$imageObj = new Image(Tools::getValue('id_image'));
echo '
<script type="text/javascript" src="../js/cropper/prototype.js"></script>
<script type="text/javascript" src="../js/cropper/scriptaculous.js"></script>
<script type="text/javascript" src="../js/cropper/builder.js"></script>
<script type="text/javascript" src="../js/cropper/dragdrop.js"></script>
<script type="text/javascript" src="../js/cropper/cropper.js"></script>
<script type="text/javascript" src="../js/cropper/loader.js"></script>
<form enctype="multipart/form-data" method="post" action="' . $currentIndex . '&imageresize&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '">
<input type="hidden" name="id_product" value="' . Tools::getValue('id_product') . '" />
<input type="hidden" name="id_category" value="' . Tools::getValue('id_category') . '" />
<input type="hidden" name="saveandstay" value="' . Tools::getValue('submitAddAndStay') . '" />
<input type="hidden" name="conf" value="' . Tools::getValue('toconf') . '" />
<input type="hidden" name="imageresize" value="imageresize" />
<input type="hidden" name="id_image" value="' . Tools::getValue('id_image') . '" />
<fieldset>
<legend><img src="../img/admin/picture.gif" />' . $this->l('Image resize') . '</legend>
' . $this->l('Using your mouse, define which area of the image is to be used for generating each type of thumbnail.') . '
<br /><br />
<img src="' . _THEME_PROD_DIR_ . $imageObj->getExistingImgPath() . '.jpg" id="testImage">
<label for="imageChoice">' . $this->l('Thumbnails format') . '</label>
<div class="margin-form"">
<select name="imageChoice" id="imageChoice">';
foreach ($imagesTypes as $type) {
echo '<option value="../img/p/' . $imageObj->getExistingImgPath() . '.jpg|' . $type['width'] . '|' . $type['height'] . '|' . $type['id_image_type'] . '">' . $type['name'] . '</option>';
}
echo ' </select>
<input type="submit" class="button" style="margin-left : 40px;" name="resize" value="' . $this->l(' Save all ') . '" />
</div>';
foreach ($imagesTypes as $type) {
echo '
<input type="hidden" name="' . $type['id_image_type'] . '_x1" id="' . $type['id_image_type'] . '_x1" value="0" />
<input type="hidden" name="' . $type['id_image_type'] . '_y1" id="' . $type['id_image_type'] . '_y1" value="0" />
<input type="hidden" name="' . $type['id_image_type'] . '_x2" id="' . $type['id_image_type'] . '_x2" value="0" />
<input type="hidden" name="' . $type['id_image_type'] . '_y2" id="' . $type['id_image_type'] . '_y2" value="0" />';
}
echo ' </fieldset>
</form>';
}
示例4: getThumbnailForListing
/**
* Old legacy way to generate a thumbnail.
*
* Use it upon a new Image management system is available.
*
* @param $imageId
* @param string $imageType
* @param string $tableName
* @param string $imageDir
* @return string The HTML < img > tag
*/
public function getThumbnailForListing($imageId, $imageType = 'jpg', $tableName = 'product', $imageDir = 'p')
{
if ($tableName == 'product') {
$image = new \Image($imageId);
$path_to_image = _PS_IMG_DIR_ . $imageDir . '/' . $image->getExistingImgPath() . '.' . $imageType;
} else {
$path_to_image = _PS_IMG_DIR_ . $imageDir . '/' . $imageId . '.' . $imageType;
}
$thumbPath = \ImageManager::thumbnail($path_to_image, $tableName . '_mini_' . $imageId . '.' . $imageType, 45, $imageType);
// because legacy uses relative path to reach a directory under root directory...
$replacement = 'src="' . $this->legacyContext->getRootUrl();
$thumbPath = preg_replace('/src="(\\.\\.\\/)+/', $replacement, $thumbPath);
return $thumbPath;
}
示例5: setItemBuys
function setItemBuys($id_order, $items)
{
if (count($items)) {
$buys = array();
foreach ($items as $item) {
$id_image = Product::getCover($item['id']);
$image_url = '';
if (sizeof($id_image) > 0) {
$image = new Image($id_image['id_image']);
// get image full URL
$image_url = _PS_BASE_URL_ . _THEME_PROD_DIR_ . $image->getExistingImgPath() . ".jpg";
}
$sql = "INSERT INTO " . _DB_PREFIX_ . "neo_items_buys (id_product, id_neo_exchange, name, price, image, created_at, status)\n VALUES ('" . $item['id'] . "','" . $id_order . "','" . pSQL($item['name']) . "','" . $item['price'] . "','" . $image_url . "',now(),1)";
Db::getInstance()->executeS($sql);
$sql = "UPDATE " . _DB_PREFIX_ . "stock_available SET quantity = quantity+(-1) WHERE id_product = '" . $item['id'] . "'";
Db::getInstance()->execute($sql);
$buys[] = '<div style="vertical-align:top"><img style="float:left;margin-right:10px;border:1px solid rgb(204,204,204);height:79px" alt="' . $item['name'] . '" src="' . $image_url . '"/> ' . $item['name'] . '<br><br>' . $item['price'] . '</div>';
}
return $buys;
} else {
return false;
}
}
示例6: displayCustomizedDatas
private function displayCustomizedDatas(&$customizedDatas, &$product, &$currency, &$image, $tokenCatalog, &$stock)
{
if (!($order = $this->loadObject(true))) {
return;
}
if (is_array($customizedDatas) and isset($customizedDatas[(int) $product['id_product']][(int) $product['id_product_attribute']])) {
if ($image = new Image($image['id_image'])) {
echo '
<tr>
<td align="center">' . (isset($image->id_image) ? cacheImage(_PS_IMG_DIR_ . 'p/' . $image->getExistingImgPath() . '.jpg', 'product_mini_' . (int) $product['id_product'] . (isset($product['id_product_attribute']) ? '_' . (int) $product['id_product_attribute'] : '') . '.jpg', 45, 'jpg') : '--') . '</td>
<td><a href="index.php?tab=AdminCatalog&id_product=' . $product['id_product'] . '&updateproduct&token=' . $tokenCatalog . '">
<span class="productName">' . $product['name'] . '</span>' . (isset($product['attributes']) ? '<br />' . $product['attributes'] : '') . '<br />
' . ($product['reference'] ? $this->l('Ref:') . ' ' . $product['reference'] : '') . (($product['reference'] and $product['supplier_reference']) ? ' / ' . $product['supplier_reference'] : '') . '</a></td>
<td align="center">' . Tools::displayPrice($product['price_wt'], $currency, false) . '</td>
<td align="center" class="productQuantity">' . $product['customizationQuantityTotal'] . '</td>
<td align="center" class="productQuantity">' . (int) $stock['quantity'] . '</td>
<td align="right">' . Tools::displayPrice($product['total_customization_wt'], $currency, false) . '</td>
</tr>';
}
foreach ($customizedDatas[(int) $product['id_product']][(int) $product['id_product_attribute']] as $customization) {
echo '
<tr>
<td colspan="2">';
foreach ($customization['datas'] as $type => $datas) {
if ($type == _CUSTOMIZE_FILE_) {
$i = 0;
echo '<ul style="margin: 0; padding: 0; list-style-type: none;">';
foreach ($datas as $data) {
echo '<li style="display: inline; margin: 2px;">
<a href="displayImage.php?img=' . $data['value'] . '&name=' . (int) $order->id . '-file' . ++$i . '" target="_blank"><img src="' . _THEME_PROD_PIC_DIR_ . $data['value'] . '_small" alt="" /></a>
</li>';
}
echo '</ul>';
} elseif ($type == _CUSTOMIZE_TEXTFIELD_) {
$i = 0;
echo '<ul style="margin-bottom: 4px; padding: 0; list-style-type: none;">';
foreach ($datas as $data) {
echo '<li>' . ($data['name'] ? $data['name'] : $this->l('Text #') . ++$i) . $this->l(':') . ' <b>' . $data['value'] . '</b></li>';
}
echo '</ul>';
}
}
echo '</td>
<td align="center"></td>
<td align="center" class="productQuantity">' . $customization['quantity'] . '</td>
<td align="center" class="productQuantity"></td>
<td align="center"></td>
</tr>';
}
}
}
示例7: ajaxProcessAddImage
public function ajaxProcessAddImage()
{
self::$currentIndex = 'index.php?tab=AdminProducts';
$allowedExtensions = array('jpeg', 'gif', 'png', 'jpg');
// max file size in bytes
$uploader = new FileUploader($allowedExtensions, $this->max_image_size);
$result = $uploader->handleUpload();
if (isset($result['success'])) {
$obj = new Image((int) $result['success']['id_image']);
// Associate image to shop from context
$shops = Shop::getContextListShopID();
$obj->associateTo($shops);
$json_shops = array();
foreach ($shops as $id_shop) {
$json_shops[$id_shop] = true;
}
$json = array('name' => $result['success']['name'], 'status' => 'ok', 'id' => $obj->id, 'path' => $obj->getExistingImgPath(), 'position' => $obj->position, 'cover' => $obj->cover, 'shops' => $json_shops);
@unlink(_PS_TMP_IMG_DIR_ . 'product_' . (int) $obj->id_product . '.jpg');
@unlink(_PS_TMP_IMG_DIR_ . 'product_mini_' . (int) $obj->id_product . '_' . $this->context->shop->id . '.jpg');
die(Tools::jsonEncode($json));
} else {
die(Tools::jsonEncode($result));
}
}
示例8: hookwatermark
public function hookwatermark($params)
{
global $smarty;
$image = new Image($params['id_image']);
$image->id_product = $params['id_product'];
$file = _PS_PROD_IMG_DIR_ . $image->getExistingImgPath() . '-watermark.jpg';
//first make a watermark image
$return = $this->watermarkByImage(_PS_PROD_IMG_DIR_ . $image->getExistingImgPath() . '.jpg', dirname(__FILE__) . '/watermark.gif', $file, 23, 0, 0, 'right');
//go through file formats defined for watermark and resize them
foreach ($this->imageTypes as $imageType) {
$newFile = _PS_PROD_IMG_DIR_ . $image->getExistingImgPath() . '-' . stripslashes($imageType['name']) . '.jpg';
if (!imageResize($file, $newFile, (int) $imageType['width'], (int) $imageType['height'])) {
$return = false;
}
}
return $return;
}
示例9: hookActionWatermark
public function hookActionWatermark($params)
{
$image = new Image($params['id_image']);
$image->id_product = $params['id_product'];
$file = _PS_PROD_IMG_DIR_ . $image->getExistingImgPath() . '-watermark.jpg';
$str_shop = '-' . (int) $this->context->shop->id;
if (Shop::getContext() != Shop::CONTEXT_SHOP || !Tools::file_exists_cache(dirname(__FILE__) . '/watermark' . $str_shop . '.gif')) {
$str_shop = '';
}
//first make a watermark image
$return = $this->watermarkByImage(_PS_PROD_IMG_DIR_ . $image->getExistingImgPath() . '.jpg', dirname(__FILE__) . '/watermark' . $str_shop . '.gif', $file, 23, 0, 0, 'right');
//go through file formats defined for watermark and resize them
foreach ($this->imageTypes as $imageType) {
$newFile = _PS_PROD_IMG_DIR_ . $image->getExistingImgPath() . '-' . stripslashes($imageType['name']) . '.jpg';
if (!ImageManager::resize($file, $newFile, (int) $imageType['width'], (int) $imageType['height'])) {
$return = false;
}
}
return $return;
}
示例10: stripslashes
$imageAlt = stripslashes($slideTitle);
if (empty($imageAlt)) {
$imageAlt = "slide";
}
if ($bgType == "image" && !empty($filename)) {
$title .= " (" . $filename . ")";
}
$postID = $slide->getID();
$tem_post_types = $slide->tem_post_types();
// print '<pre>';
// print_r(Tools::getvalue('id'));
// print '</pre>';
$sdsrevsliderid = Tools::getvalue('id');
if (isset($sdsrevsliderid) && !empty($sdsrevsliderid)) {
$RevSlider = new RevSlider();
$img_type_set = $RevSlider->GetSliderImgSettings($sdsrevsliderid);
}
if (!isset($img_type_set) && empty($img_type_set)) {
$img_type_set = 'home_default';
}
// start get image thumbnail
$prdid_image = Product::getCover($postID);
if (sizeof($prdid_image) > 0) {
$prdimage = new Image($prdid_image['id_image']);
$prdimage_url = _PS_BASE_URL_ . _THEME_PROD_DIR_ . $prdimage->getExistingImgPath() . "-" . $img_type_set . ".jpg";
}
$urlImageForView = $prdimage_url;
// end get image thumbnail
// $urlEditSlide = UniteFunctionsWPRev::getUrlEditPost($postID);
$urlEditSlide = 'index.php?controller=AdminProducts&id_product=' . $postID . '&updateproduct&token=' . Tools::getAdminTokenLite('AdminProducts');
$linkEdit = UniteFunctionsRev::getHtmlLink($urlEditSlide, $title, "", "", true);
示例11: viewDetails
//.........这里部分代码省略.........
$image = array();
if (isset($product['product_attribute_id']) and (int) $product['product_attribute_id']) {
$image = Db::getInstance()->getRow('
SELECT id_image
FROM ' . _DB_PREFIX_ . 'product_attribute_image
WHERE id_product_attribute = ' . (int) $product['product_attribute_id']);
}
if (!isset($image['id_image']) or !$image['id_image']) {
$image = Db::getInstance()->getRow('
SELECT id_image
FROM ' . _DB_PREFIX_ . 'image
WHERE id_product = ' . (int) $product['product_id'] . ' AND cover = 1');
}
$stock = Db::getInstance()->getRow('
SELECT ' . ($product['product_attribute_id'] ? 'pa' : 'p') . '.quantity
FROM ' . _DB_PREFIX_ . 'product p
' . ($product['product_attribute_id'] ? 'LEFT JOIN ' . _DB_PREFIX_ . 'product_attribute pa ON p.id_product = pa.id_product' : '') . '
WHERE p.id_product = ' . (int) $product['product_id'] . '
' . ($product['product_attribute_id'] ? 'AND pa.id_product_attribute = ' . (int) $product['product_attribute_id'] : ''));
if (isset($image['id_image'])) {
$target = _PS_TMP_IMG_DIR_ . 'product_mini_' . (int) $product['product_id'] . (isset($product['product_attribute_id']) ? '_' . (int) $product['product_attribute_id'] : '') . '.jpg';
if (file_exists($target)) {
$products[$k]['image_size'] = getimagesize($target);
}
}
// Customization display
$this->displayCustomizedDatas($customizedDatas, $product, $currency, $image, $tokenCatalog, $k);
// Normal display
if ($product['product_quantity'] > $product['customizationQuantityTotal']) {
$quantity = $product['product_quantity'] - $product['customizationQuantityTotal'];
$imageObj = new Image($image['id_image']);
echo '
<tr' . ((isset($image['id_image']) and isset($products[$k]['image_size'])) ? ' height="' . ($products[$k]['image_size'][1] + 7) . '"' : '') . '>
<td align="center">' . (isset($image['id_image']) ? cacheImage(_PS_IMG_DIR_ . 'p/' . $imageObj->getExistingImgPath() . '.jpg', 'product_mini_' . (int) $product['product_id'] . (isset($product['product_attribute_id']) ? '_' . (int) $product['product_attribute_id'] : '') . '.jpg', 45, 'jpg') : '--') . '</td>
<td><a href="index.php?tab=AdminCatalog&id_product=' . $product['product_id'] . '&updateproduct&token=' . $tokenCatalog . '">
<span class="productName">' . $product['product_name'] . '</span><br />
' . ($product['product_reference'] ? $this->l('Ref:') . ' ' . $product['product_reference'] . '<br />' : '') . ($product['product_supplier_reference'] ? $this->l('Ref Supplier:') . ' ' . $product['product_supplier_reference'] : '') . '</a></td>
<td align="center">' . Tools::displayPrice($product_price, $currency, false) . '</td>
<td align="center" class="productQuantity" ' . ($quantity > 1 ? 'style="font-weight:700;font-size:1.1em;color:red"' : '') . '>' . (int) $quantity . '</td>
' . ($order->hasBeenPaid() ? '<td align="center" class="productQuantity">' . (int) $product['product_quantity_refunded'] . '</td>' : '') . '
' . ($order->hasBeenDelivered() ? '<td align="center" class="productQuantity">' . (int) $product['product_quantity_return'] . '</td>' : '') . '
<td align="center" class="productQuantity">' . (int) $stock['quantity'] . '</td>
<td align="center">' . Tools::displayPrice(Tools::ps_round($product_price, 2) * ((int) $product['product_quantity'] - $product['customizationQuantityTotal']), $currency, false) . '</td>
<td align="center" class="cancelCheck">
<input type="hidden" name="totalQtyReturn" id="totalQtyReturn" value="' . (int) $product['product_quantity_return'] . '" />
<input type="hidden" name="totalQty" id="totalQty" value="' . (int) $product['product_quantity'] . '" />
<input type="hidden" name="productName" id="productName" value="' . $product['product_name'] . '" />';
if ((!$order->hasBeenDelivered() or Configuration::get('PS_ORDER_RETURN')) and (int) $product['product_quantity_return'] < (int) $product['product_quantity']) {
echo '
<input type="checkbox" name="id_order_detail[' . $k . ']" id="id_order_detail[' . $k . ']" value="' . $product['id_order_detail'] . '" onchange="setCancelQuantity(this, ' . (int) $product['id_order_detail'] . ', ' . (int) ($product['product_quantity_in_stock'] - $product['customizationQuantityTotal'] - $product['product_quantity_reinjected']) . ')" ' . ((int) ($product['product_quantity_return'] + $product['product_quantity_refunded']) >= (int) $product['product_quantity'] ? 'disabled="disabled" ' : '') . '/>';
} else {
echo '--';
}
echo '
</td>
<td class="cancelQuantity">';
if ((int) ($product['product_quantity_return'] + $product['product_quantity_refunded']) >= (int) $product['product_quantity']) {
echo '<input type="hidden" name="cancelQuantity[' . $k . ']" value="0" />';
} elseif (!$order->hasBeenDelivered() or Configuration::get('PS_ORDER_RETURN')) {
echo '
<input type="text" id="cancelQuantity_' . (int) $product['id_order_detail'] . '" name="cancelQuantity[' . $k . ']" size="2" onclick="selectCheckbox(this);" value="" /> ';
}
echo $this->getCancelledProductNumber($order, $product) . '
</td>
</tr>';
}
示例12: Link
<?php
include_once '../../config/config.inc.php';
include_once '../../init.php';
//$this->instant_search = Tools::getValue('instantSearch');
//$this->ajax_search = Tools::getValue('ajaxSearch');
//parent::initContent();
$query = Tools::replaceAccentedChars(urldecode(Tools::getValue('q')));
$original_query = Tools::getValue('q');
$searchResults = Search::find((int) Tools::getValue('id_lang'), $query, 1, 10, 'position', 'desc', true);
foreach ($searchResults as &$product) {
//$product['product_link'] = $this->context->link->getProductLink($product['id_product'], $product['prewrite'], $product['crewrite']);
$links = new Link();
$product['product_link'] = $links->getProductLink($product['id_product'], $product['prewrite'], $product['crewrite']);
/**
*Get product cover
*/
$tdgetpover = Product::getCover($product['id_product']);
$cproduct_image = new Image($tdgetpover['id_image']);
$cproductimg_url = $cproduct_image->getExistingImgPath() . '-small_default.jpg';
$product['ajaxsearchimage'] = $cproductimg_url;
}
die(Tools::jsonEncode($searchResults));
示例13: hookActionWatermark
public function hookActionWatermark($params)
{
$image = new Image($params['id_image']);
$image->id_product = $params['id_product'];
$file = _PS_PROD_IMG_DIR_ . $image->getExistingImgPath() . '-watermark.jpg';
$file_org = _PS_PROD_IMG_DIR_ . $image->getExistingImgPath() . '.jpg';
$str_shop = '-' . (int) $this->context->shop->id;
if (Shop::getContext() != Shop::CONTEXT_SHOP || !Tools::file_exists_cache(dirname(__FILE__) . '/watermark' . $str_shop . '.gif')) {
$str_shop = '';
}
//first make a watermark image
$return = $this->watermarkByImage(_PS_PROD_IMG_DIR_ . $image->getExistingImgPath() . '.jpg', dirname(__FILE__) . '/watermark' . $str_shop . '.gif', $file, 23, 0, 0, 'right');
if (!Configuration::get('WATERMARK_HASH')) {
Configuration::updateValue('WATERMARK_HASH', Tools::passwdGen(10));
}
if (isset($params['image_type']) && is_array($params['image_type'])) {
$this->imageTypes = array_intersect($this->imageTypes, $params['image_type']);
}
//go through file formats defined for watermark and resize them
foreach ($this->imageTypes as $imageType) {
$newFile = _PS_PROD_IMG_DIR_ . $image->getExistingImgPath() . '-' . stripslashes($imageType['name']) . '.jpg';
if (!ImageManager::resize($file, $newFile, (int) $imageType['width'], (int) $imageType['height'])) {
$return = false;
}
$new_file_org = _PS_PROD_IMG_DIR_ . $image->getExistingImgPath() . '-' . stripslashes($imageType['name']) . '-' . Configuration::get('WATERMARK_HASH') . '.jpg';
if (!ImageManager::resize($file_org, $new_file_org, (int) $imageType['width'], (int) $imageType['height'])) {
$return = false;
}
}
return $return;
}
示例14: getProductsInfo
private function getProductsInfo()
{
if ((int) $this->product_id < 1) {
return false;
}
$sel_total_ordered = '';
$query_where_parts = array();
$id_shop = (int) $this->def_shop;
if (!empty($this->shop_id) && (int) $this->shop_id != -1) {
$query_where_parts[] = 'o.id_shop = ' . (int) $this->shop_id;
$sel_total_ordered = ' AND id_shop = ' . (int) $this->shop_id;
$id_shop = (int) $this->shop_id;
}
// Get product information
$product_obj = new DbQuery();
$product_obj->select("\r\n\t\t\tp.id_product,\r\n\t\t\tpl.name,\r\n\t\t\tp.price AS default_price,\r\n\t\t\tp.wholesale_price AS default_wholesale_price,\r\n\t\t\tsa.quantity,\r\n\t\t\tp.reference AS sku,\r\n\t\t\tif (p.active = 1, 'Enabled', 'Disabled') AS active,\r\n\t\t\ti.id_image,\r\n\t\t\tps.price AS price,\r\n\t\t\tps.wholesale_price,\r\n\t\t\ts.name AS shop_name,\r\n\t\t\t(SELECT SUM(product_quantity) FROM " . _DB_PREFIX_ . 'order_detail WHERE product_id = p.id_product' . pSQL($sel_total_ordered) . ') AS total_ordered
');
$product_obj->from('product', 'p');
$product_obj->leftJoin('product_lang', 'pl', 'pl.id_product = p.id_product AND pl.id_lang = ' . (int) $this->def_lang);
$product_obj->leftJoin('image', 'i', 'i.id_product = p.id_product AND i.cover = 1');
$product_obj->leftJoin('stock_available', 'sa', 'p.id_product = sa.id_product AND sa.id_product_attribute = 0');
$product_obj->leftJoin('product_shop', 'ps', 'ps.id_product = p.id_product AND ps.id_shop = ' . (int) $id_shop);
$product_obj->leftJoin('shop', 's', 's.id_shop = ' . (int) $id_shop);
$product_obj->where('p.id_product = ' . (int) $this->product_id);
$product_obj->groupBy('p.id_product');
$product_sql = $product_obj->build();
$product = Db::getInstance()->executeS($product_sql);
$product = array_shift($product);
if (!$product['total_ordered']) {
$product['total_ordered'] = 0;
}
// Convert price
if ($this->currency_code != $this->def_currency) {
$product['price'] = $this->convertPrice($product['price'], $this->def_currency);
$product['wholesale_price'] = $this->convertPrice($product['wholesale_price'], $this->def_currency);
}
// Form price
$product['price'] = $this->displayPrice($product['price'], $this->currency_code, true);
$product['wholesale_price'] = $this->displayPrice($product['wholesale_price'], $this->currency_code, true);
// Get product images
$id_image = $product['id_image'];
$image_info = new Image($id_image);
$home_type = 'home_';
$thickbox_type = 'thickbox_';
$default = 'default';
if (file_exists(_PS_PROD_IMG_DIR_ . $image_info->getExistingImgPath() . '-' . $home_type . $default . '.jpg')) {
$product['id_image'] = _PS_BASE_URL_ . _THEME_PROD_DIR_ . $image_info->getExistingImgPath() . '-' . $home_type . $default . '.jpg';
} else {
$product['id_image'] = '';
}
if (file_exists(_PS_PROD_IMG_DIR_ . $image_info->getExistingImgPath() . '-' . $thickbox_type . $default . '.jpg')) {
$product['id_image_large'] = _PS_BASE_URL_ . _THEME_PROD_DIR_ . $image_info->getExistingImgPath() . '-' . $thickbox_type . $default . '.jpg';
} else {
$product['id_image_large'] = '';
}
return $product;
}
示例15: getPrestashopPreferences
private function getPrestashopPreferences($post)
{
$customer_fields = Context::getContext()->customer->getFields();
$cart = Context::getContext()->cart;
//Get shipment data
$address_delivery = new Address((int) $cart->id_address_delivery);
$shipments = array('receiver_address' => array('floor' => '-', 'zip_code' => $address_delivery->postcode, 'street_name' => $address_delivery->address1 . ' - ' . $address_delivery->address2 . ' - ' . $address_delivery->city . '/' . $address_delivery->country, 'apartment' => '-', 'street_number' => '-'));
// Get costumer data
$address_invoice = new Address((int) $cart->id_address_invoice);
$phone = $address_invoice->phone;
$phone .= $phone == '' ? '' : '|';
$phone .= $address_invoice->phone_mobile;
$customer_data = array('first_name' => $customer_fields['firstname'], 'last_name' => $customer_fields['lastname'], 'email' => $customer_fields['email'], 'phone' => array('area_code' => '-', 'number' => $phone), 'address' => array('zip_code' => $address_invoice->postcode, 'street_name' => $address_invoice->address1 . ' - ' . $address_invoice->address2 . ' - ' . $address_invoice->city . '/' . $address_invoice->country, 'street_number' => '-'), 'identification' => array('number' => $post != null && array_key_exists('docNumber', $post) ? $post['docNumber'] : '', 'type' => $post != null && array_key_exists('docType', $post) ? $post['docType'] : ''));
//items
$image_url = '';
$products = $cart->getProducts();
$items = array();
$summary = '';
foreach ($products as $key => $product) {
$image_url = '';
// get image URL
if (!empty($product['id_image'])) {
$image = new Image($product['id_image']);
$image_url = _PS_BASE_URL_ . _THEME_PROD_DIR_ . $image->getExistingImgPath() . '.' . $image->image_format;
}
$item = array('id' => $product['id_product'], 'title' => $product['name'], 'description' => $product['description_short'], 'quantity' => $product['quantity'], 'unit_price' => $product['price_wt'], 'picture_url' => $image_url, 'category_id' => Configuration::get('MERCADOPAGO_CATEGORY'));
if ($key == 0) {
$summary .= $product['name'];
} else {
$summary .= ', ' . $product['name'];
}
$items[] = $item;
}
// include shipping cost
$shipping_cost = (double) $cart->getOrderTotal(true, Cart::ONLY_SHIPPING);
if ($shipping_cost > 0) {
$item = array('title' => 'Shipping', 'description' => 'Shipping service used by store', 'quantity' => 1, 'unit_price' => $shipping_cost, 'category_id' => Configuration::get('MERCADOPAGO_CATEGORY'));
$items[] = $item;
}
// include wrapping cost
$wrapping_cost = (double) $cart->getOrderTotal(true, Cart::ONLY_WRAPPING);
if ($wrapping_cost > 0) {
$item = array('title' => 'Wrapping', 'description' => 'Wrapping service used by store', 'quantity' => 1, 'unit_price' => $wrapping_cost, 'category_id' => Configuration::get('MERCADOPAGO_CATEGORY'));
$items[] = $item;
}
// include discounts
$discounts = (double) $cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS);
if ($discounts > 0) {
$item = array('title' => 'Discount', 'description' => 'Discount provided by store', 'quantity' => 1, 'unit_price' => -$discounts, 'category_id' => Configuration::get('MERCADOPAGO_CATEGORY'));
$items[] = $item;
}
$data = array('external_reference' => $cart->id, 'customer' => $customer_data, 'items' => $items, 'shipments' => $shipments);
if (!$this->mercadopago->isTestUser()) {
switch (Configuration::get('MERCADOPAGO_COUNTRY')) {
case 'MLB':
$data['sponsor_id'] = 178326379;
break;
case 'MLM':
$data['sponsor_id'] = 187899553;
break;
case 'MLA':
$data['sponsor_id'] = 187899872;
break;
case 'MCO':
$data['sponsor_id'] = 187900060;
break;
case 'MLV':
$data['sponsor_id'] = 187900246;
break;
case 'MLC':
$data['sponsor_id'] = 187900485;
break;
}
}
if ($post != null) {
$cart = Context::getContext()->cart;
$data['reason'] = $summary;
$data['amount'] = (double) number_format($cart->getOrderTotal(true, Cart::BOTH), 2, '.', '');
$data['payer_email'] = $customer_fields['email'];
$data['notification_url'] = $this->link->getModuleLink('mercadopago', 'notification', array(), Configuration::get('PS_SSL_ENABLED'), null, null, false) . '?checkout=custom&';
// add only for creditcard
if (array_key_exists('card_token_id', $post)) {
$data['card_token_id'] = $post['card_token_id'];
$data['installments'] = (int) $post['installments'];
// add only it has issuer id
if (array_key_exists('issuersOptions', $post)) {
$data['card_issuer_id'] = (int) $post['issuersOptions'];
}
}
$data['payment_method_id'] = $post['payment_method_id'];
} else {
$data['auto_return'] = Configuration::get('MERCADOPAGO_AUTO_RETURN') == 'approved' ? 'approved' : '';
$data['back_urls']['success'] = $this->link->getModuleLink('mercadopago', 'standardreturn', array(), Configuration::get('PS_SSL_ENABLED'), null, null, false);
$data['back_urls']['failure'] = $this->link->getPageLink('order-opc', Configuration::get('PS_SSL_ENABLED'), null, null, false, null);
$data['back_urls']['pending'] = $this->link->getModuleLink('mercadopago', 'standardreturn', array(), Configuration::get('PS_SSL_ENABLED'), null, null, false);
$data['payment_methods']['excluded_payment_methods'] = $this->getExcludedPaymentMethods();
$data['payment_methods']['excluded_payment_types'] = array();
$data['payment_methods']['installments'] = (int) Configuration::get('MERCADOPAGO_INSTALLMENTS');
$data['notification_url'] = $this->link->getModuleLink('mercadopago', 'notification', array(), Configuration::get('PS_SSL_ENABLED'), null, null, false) . '?checkout=standard&';
// swap to payer index since customer is only for transparent
//.........这里部分代码省略.........