本文整理汇总了PHP中ProductDownload::getTextLink方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductDownload::getTextLink方法的具体用法?PHP ProductDownload::getTextLink怎么用?PHP ProductDownload::getTextLink使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProductDownload
的用法示例。
在下文中一共展示了ProductDownload::getTextLink方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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
//.........这里部分代码省略.........
示例2: addWithemail
public function addWithemail($autodate = true, $templateVars = false)
{
if (!parent::add($autodate)) {
return false;
}
$lastOrderState = $this->getLastOrderState($this->id_order);
$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` = ' . intval($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}' => intval($this->id_order));
if ($templateVars) {
$data = array_merge($data, $templateVars);
}
$order = new Order(intval($this->id_order));
$data['{total_paid}'] = Tools::displayPrice(floatval($order->total_paid), new Currency(intval($order->id_currency)), false, false);
$data['{order_name}'] = sprintf("#%06d", intval($order->id));
// additionnal links for download virtual product
if ($virtualProducts = $order->getVirtualProducts() and $this->id_order_state == _PS_OS_PAYMENT_) {
global $smarty;
$display = '';
$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;
$assign[$key]['link'] = $product_download->getTextLink(false, $virtualProduct['download_hash']);
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);
$iso = Language::getIsoById(intval($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;
$subject = 'Virtual product to download';
Mail::Send(intval($order->id_lang), 'download_product', (is_array($_LANGMAIL) and key_exists($subject, $_LANGMAIL)) ? $_LANGMAIL[$subject] : $subject, $data, $result['email'], $result['firstname'] . ' ' . $result['lastname']);
}
if (Validate::isLoadedObject($order)) {
Mail::Send(intval($order->id_lang), $result['template'], $topic, $data, $result['email'], $result['firstname'] . ' ' . $result['lastname']);
}
}
if ($lastOrderState->id !== $this->id_order_state) {
Hook::postUpdateOrderStatus($this->id_order_state, intval($this->id_order));
}
return true;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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_) {
//.........这里部分代码省略.........