Новости Joomla

0 Пользователей и 1 Гость просматривают эту тему.
  • 12 Ответов
  • 2079 Просмотров
*

stepan39

  • Захожу иногда
  • 497
  • 27 / 0
Производитель в инвойсе
« : 24.07.2019, 21:56:12 »
Привет!
Появилась необходимость отображения в инвойсе рядом с названием товара названия его производителя.
В переопределенном макете /templates/мой шаблон/html/com_virtuemart/invoice/invoice_items.php про товар вижу следующее
Код
<a href="<?php echo $product_link; ?>"><?php echo $item->order_item_name; ?></a>
Добавление что-то типа
Код
<?php echo $item->manufacturer; ?>
не работает.

Подскажите рабочий код. Ссыль на производителя не нужна, только название.

VirtueMart 3.2.1, Joomla 3.9.10
*

draff

  • Гуру
  • 5803
  • 434 / 7
  • ищу работу
Re: Производитель в инвойсе
« Ответ #1 : 25.07.2019, 09:17:22 »
Не рабочий, но подскажу направление.
Код
$metaObj = VmModel::getModel('manufacturer')->getManufacturer($manufacturer_id);
$mf_name = $metaObj->mf_name;
Нужно получить у каждого товара производителя $manufacturer_id.
*

stepan39

  • Захожу иногда
  • 497
  • 27 / 0
Re: Производитель в инвойсе
« Ответ #2 : 27.07.2019, 22:37:42 »
Не рабочий, но подскажу направление.
Код
$metaObj = VmModel::getModel('manufacturer')->getManufacturer($manufacturer_id);
$mf_name = $metaObj->mf_name;
Нужно получить у каждого товара производителя $manufacturer_id.
Спасибо за "наводку".
*

gartes

  • Завсегдатай
  • 1859
  • 142 / 6
  • Е = mс²
Re: Производитель в инвойсе
« Ответ #3 : 31.07.2019, 21:02:57 »
Тогда правильно будет так
Код
$metaObj = VmModel::getModel('manufacturer')->getManufacturer( $item->manufacturer_id);
$mf_name = $metaObj->mf_name;
Просто посмотрите что у вас в этой переменной $item где то так
Код
echo'<pre>';print_r( $item );echo'</pre>'.__FILE__.' '.__LINE__;
die(__FILE__ .' Lines '. __LINE__ );
*

draff

  • Гуру
  • 5803
  • 434 / 7
  • ищу работу
Re: Производитель в инвойсе
« Ответ #4 : 31.07.2019, 22:46:06 »
Тогда правильно будет так
Код
$metaObj = VmModel::getModel('manufacturer')->getManufacturer( $item->manufacturer_id);
$mf_name = $metaObj->mf_name;
Ну если в письме берутся данные о продукте с заказа, в котором не указываться производитель, то это неправильно.
А вот правильный полный код, где получаю имя производителя в файле mail_html_pricelist.php .
Код
$pM = VmModel::getModel('product');
foreach($this->orderDetails['items'] as $item) {
$product = $pM->getProduct($item->virtuemart_product_id);
$metaObj = VmModel::getModel('manufacturer')->getManufacturer($product->virtuemart_manufacturer_id);
$mf_name = $metaObj->mf_name; // Имя производителя
}
*

stepan39

  • Захожу иногда
  • 497
  • 27 / 0
Re: Производитель в инвойсе
« Ответ #5 : 01.08.2019, 10:07:35 »
А вот правильный полный код, где получаю имя производителя в файле mail_html_pricelist.php .
Инвойс (не письмо) формируется тут /templates/мой шаблон/html/com_virtuemart/invoice/invoice_items.php

Пытался использовать предложенный вами код выводя в нужном месте так:
Код
<?php echo $item->mf_name; ?>

К сожалению не работает.
*

draff

  • Гуру
  • 5803
  • 434 / 7
  • ищу работу
Re: Производитель в инвойсе
« Ответ #6 : 01.08.2019, 10:45:09 »
Тогда разместите код в  /templates/мой шаблон/html/com_virtuemart/invoice/invoice_items.php
« Последнее редактирование: 01.08.2019, 11:18:04 от draff »
*

stepan39

  • Захожу иногда
  • 497
  • 27 / 0
Re: Производитель в инвойсе
« Ответ #7 : 01.08.2019, 22:03:19 »
Тогда разместите код в  /templates/мой шаблон/html/com_virtuemart/invoice/invoice_items.php
я так и сделал, но вывод не работает
*

gartes

  • Завсегдатай
  • 1859
  • 142 / 6
  • Е = mс²
Re: Производитель в инвойсе
« Ответ #8 : 02.08.2019, 06:00:59 »
a так ?
Код: php
echo'<pre>';print_r( $item );echo'</pre>'.__FILE__.' '.__LINE__;
die(__FILE__ .' Lines '. __LINE__ );
*

draff

  • Гуру
  • 5803
  • 434 / 7
  • ищу работу
Re: Производитель в инвойсе
« Ответ #9 : 02.08.2019, 08:27:45 »
я так и сделал, но вывод не работает
А вообще изменение проверить- добавьте любой текст в файл в нужное место.
п.с.
В шаблоне переопределение не подключается. Замените файл в папке компонента Вирт.
« Последнее редактирование: 02.08.2019, 08:36:48 от draff »
*

stepan39

  • Захожу иногда
  • 497
  • 27 / 0
Re: Производитель в инвойсе
« Ответ #10 : 02.08.2019, 09:48:29 »
В шаблоне переопределение не подключается
У меня кастомный файл сильно отличается Вашего, видимо версия другая. К сожалению, пробовать можно только на боевом сайте, уже были жалобы от клиентов....
То все позиции одинаковые, то отсутствуют.
Какие изменения нужно внести в него? Переопределение, к сожалению, принципиально.
Мой кастом (без вставок по производителю):
Код
<?php
/**
*
* Order items view
*
* @package VirtueMart
* @subpackage Orders
* @author Max Milbers, Valerie Isaksen
* @link http://www.virtuemart.net
* [member=126442]copyright[/member] Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* @version $Id: details_items.php 5432 2012-02-14 02:20:35Z Milbo $
*/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
// Get Vm version
$version = VmConfig::getInstalledVersion();
$version = str_replace(array('.', ','), '' , $version);
$version = intval($version);

$colspan=8;

if ($this->doctype != 'invoice') {
    $colspan -= 4;
} elseif ( ! VmConfig::get('show_tax')) {
    $colspan -= 1;
}

if ($version >= 3010)
{
  $handled = array();
  $discountsBill = false;
  $taxBill = false;
  $vats = 0;
  foreach($this->orderDetails['calc_rules'] as $rule){
  if(isset($sumRules[$rule->virtuemart_calc_id])){ // or $rule->calc_kind=='payment' or $rule->calc_kind=='shipment'){
  continue;
  }
  $handled[$rule->virtuemart_calc_id] = true;
  $r = new stdClass();
  $r->calc_result = $rule->calc_result;
  $r->calc_amount = $rule->calc_amount;
  $r->calc_rule_name = $rule->calc_rule_name;
  $r->calc_kind = $rule->calc_kind;
  $r->calc_value = $rule->calc_value;

  if($rule->calc_kind == 'DBTaxRulesBill' or $rule->calc_kind == 'DATaxRulesBill'){
  $discountsBill[$rule->virtuemart_calc_id] = $r;
  }
  if($rule->calc_kind == 'taxRulesBill' or $rule->calc_kind == 'VatTax' or $rule->calc_kind=='payment' or $rule->calc_kind=='shipment'){
  //vmdebug('method rule',$rule);
  $r->label = shopFunctionsF::getTaxNameWithValue($rule->calc_rule_name,$rule->calc_value);
  if(isset($taxBill[$rule->virtuemart_calc_id])){
  $taxBill[$rule->virtuemart_calc_id]->calc_amount += $r->calc_amount;
  } else {
  $taxBill[$rule->virtuemart_calc_id] = $r;
  }

  }

  }
}
?>
<table class="html-email" width="580" cellspacing="0" cellpadding="5" border="0" style="border-collapse: collapse; font-size: 12px;">
<tr align="left" class="sectiontableheader">
<th align="left" bgcolor="#EEEEEE" style="border: 1px solid #CCCCCC;"><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_SKU')?></th>
<th align="center" bgcolor="#EEEEEE" colspan="2" style="border: 1px solid #CCCCCC;"><?php echo vmText::_('COM_VIRTUEMART_PRODUCT_NAME_TITLE')?></th>
<th align="center" bgcolor="#EEEEEE" style="border: 1px solid #CCCCCC;"><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_PRODUCT_STATUS')?></th>
<?php if ($this->doctype == 'invoice') { ?>
<th align="center" bgcolor="#EEEEEE" style="border: 1px solid #CCCCCC;"><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_PRICE')?></th>
<?php } ?>
<th align="center" bgcolor="#EEEEEE" style="border: 1px solid #CCCCCC;"><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_QTY')?></th>
<?php if ($this->doctype == 'invoice') { ?>
<?php if ( VmConfig::get('show_tax')) { ?>
<th align="center" bgcolor="#EEEEEE" style="border: 1px solid #CCCCCC;"><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_PRODUCT_TAX')?></th>
<?php } ?>
<th align="center" bgcolor="#EEEEEE" style="border: 1px solid #CCCCCC;"><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_SUBTOTAL_DISCOUNT_AMOUNT')?></th>
<th align="right" bgcolor="#EEEEEE" style="border: 1px solid #CCCCCC;"><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_TOTAL')?></th>
<?php } ?>
</tr>
<?php
$menuItemID = shopFunctionsF::getMenuItemId($this->orderDetails['details']['BT']->order_language);
  if(!class_exists('VirtueMartModelCustomfields'))require(VMPATH_ADMIN.DS.'models'.DS.'customfields.php');
  if ($version >= 3008) {
  VirtueMartModelCustomfields::$useAbsUrls = ($this->isMail or $this->isPdf);
  }
foreach($this->orderDetails['items'] as $item) {
$qtt = $item->product_quantity ;
$product_link = JURI::root(). JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' . $item->virtuemart_category_id .'&virtuemart_product_id=' . $item->virtuemart_product_id);
?>

<tr valign="top">
<td align="left" style="border: 1px solid #CCCCCC;">
<?php echo $item->order_item_sku; ?>
</td>
<td align="left" colspan="2" style="border: 1px solid #CCCCCC;">
<p>
<a href="<?php echo $product_link; ?>"><?php echo $item->order_item_name; ?></a>

</p>
<?php
$product_attribute = VirtueMartModelCustomfields::CustomsFieldOrderDisplay($item,'FE');
echo '<p>' . strip_tags($product_attribute, '<br>'). '</p>';
?>
</td>
<td align="center" style="border: 1px solid #CCCCCC;">
<?php echo $this->orderstatuses[$item->order_status]; ?>
</td>
<?php if ($this->doctype == 'invoice') { ?>
<td align="right"   class="priceCol" style="border: 1px solid #CCCCCC; white-space: nowrap;">
<?php
$item->product_discountedPriceWithoutTax = (float) $item->product_discountedPriceWithoutTax;
if (!empty($item->product_priceWithoutTax) && $item->product_discountedPriceWithoutTax != $item->product_priceWithoutTax) {
  echo '<del>'.$this->currency->priceDisplay($item->product_item_price, $this->currency).'</del><br />';
  echo '<span >'.$this->currency->priceDisplay($item->product_discountedPriceWithoutTax, $this->currency).'</span><br />';
} else {
  echo '<span >'.$this->currency->priceDisplay($item->product_item_price, $this->currency).'</span><br />';
}
?>
</td>
<?php } ?>
<td align="right" style="border: 1px solid #CCCCCC;">
<?php echo $qtt; ?>
</td>
<?php if ($this->doctype == 'invoice') { ?>
<?php if ( VmConfig::get('show_tax')) { ?>
<td align="right" class="priceCol" style="border: 1px solid #CCCCCC; white-space: nowrap;"><?php echo "<span  class='priceColor2'>".$this->currency->priceDisplay($item->product_tax ,$this->currency, $qtt)."</span>" ?></td>
<?php } ?>
<td align="right" class="priceCol" style="border: 1px solid #CCCCCC; white-space: nowrap;">
<?php echo  $this->currency->priceDisplay( $item->product_subtotal_discount, $this->currency );  //No quantity is already stored with it ?>
</td>
<td align="right"  class="priceCol" style="border: 1px solid #CCCCCC; white-space: nowrap;">
<?php
$item->product_basePriceWithTax = (float) $item->product_basePriceWithTax;
$class = '';
if(!empty($item->product_basePriceWithTax) && $item->product_basePriceWithTax != $item->product_final_price ) {
echo '<del>'.$this->currency->priceDisplay($item->product_basePriceWithTax,$this->currency,$qtt).'</del><br />' ;
} elseif (empty($item->product_basePriceWithTax) && $item->product_item_price != $item->product_final_price) {
echo '<del>' . $this->currency->priceDisplay($item->product_item_price,$this->currency,$qtt). '</del><br />';
}
echo $this->currency->priceDisplay(  $item->product_subtotal_with_tax ,$this->currency); //No quantity or you must use product_final_price ?>
</td>
<?php } ?>
</tr>
<?php
}
?>
<?php if ($this->doctype == 'invoice') { ?>
<tr class="sectiontableentry1">
<td colspan="6" align="right" style="border: 1px solid #CCCCCC;"><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_PRODUCT_PRICES_TOTAL'); ?></td>
<?php if ( VmConfig::get('show_tax')) { ?>
<td align="right" style="border: 1px solid #CCCCCC; white-space: nowrap;"><?php echo "<span  class='priceColor2'>".$this->currency->priceDisplay($this->orderDetails['details']['BT']->order_tax, $this->currency)."</span>" ?></td>
<?php } ?>
<td align="right" style="border: 1px solid #CCCCCC; white-space: nowrap;"><?php echo "<span  class='priceColor2'>".$this->currency->priceDisplay($this->orderDetails['details']['BT']->order_discountAmount, $this->currency)."</span>" ?></td>
<td align="right" style="border: 1px solid #CCCCCC; white-space: nowrap;"><?php echo $this->currency->priceDisplay($this->orderDetails['details']['BT']->order_salesPrice, $this->currency)?></td>
</tr>
<?php
if ($this->orderDetails['details']['BT']->coupon_discount <> 0.00) {
  $coupon_code=$this->orderDetails['details']['BT']->coupon_code?' ('.$this->orderDetails['details']['BT']->coupon_code.')':'';
?>
<tr>
<td align="right" class="pricePad" colspan="6" style="border: 1px solid #CCCCCC;"><?php echo vmText::_('COM_VIRTUEMART_COUPON_DISCOUNT').$coupon_code ?></td>
<?php if ( VmConfig::get('show_tax')) { ?>
<td align="right" style="border: 1px solid #CCCCCC;"></td>
<?php } ?>
<td align="right" style="border: 1px solid #CCCCCC;"></td>
<td align="right" style="border: 1px solid #CCCCCC; white-space: nowrap;"><?php echo $this->currency->priceDisplay($this->orderDetails['details']['BT']->coupon_discount, $this->currency); ?></td>
</tr>
<?php  } ?>
<?php
foreach($this->orderDetails['calc_rules'] as $rule){
if ($rule->calc_kind == 'DBTaxRulesBill' or $rule->calc_kind == 'DATaxRulesBill') { ?>
<tr >
<td colspan="6" align="right" class="pricePad" style="border: 1px solid #CCCCCC;"><?php echo $rule->calc_rule_name ?></td>
<?php if ( VmConfig::get('show_tax')) { ?>
<td align="right" style="border: 1px solid #CCCCCC;"></td>
<?php } ?>
<td align="right" style="border: 1px solid #CCCCCC; white-space: nowrap;"><?php echo $this->currency->priceDisplay($rule->calc_amount, $this->currency); ?></td>
<td align="right" style="border: 1px solid #CCCCCC; white-space: nowrap;"><?php echo $this->currency->priceDisplay($rule->calc_amount, $this->currency); ?></td>
</tr>
<?php
} elseif ($rule->calc_kind == 'taxRulesBill') {
?>
<tr >
<td colspan="6"  align="right" class="pricePad" style="border: 1px solid #CCCCCC;"><?php echo $rule->calc_rule_name ?></td>
<?php if ( VmConfig::get('show_tax')) { ?>
<td align="right" style="border: 1px solid #CCCCCC; white-space: nowrap;"><?php echo $this->currency->priceDisplay($rule->calc_amount, $this->currency); ?></td>
<?php } ?>
<td align="right" style="border: 1px solid #CCCCCC;"></td>
<td align="right" style="border: 1px solid #CCCCCC; white-space: nowrap;"><?php echo $this->currency->priceDisplay($rule->calc_amount, $this->currency); ?></td>
</tr>
<?php
}
}
?>
<tr>
<td align="right" class="pricePad" colspan="6" style="border: 1px solid #CCCCCC;"><?php echo strip_tags(str_replace('</span>', ' ', $this->orderDetails['shipmentName']))?></td>
<?php if ( VmConfig::get('show_tax')) { ?>
<td align="right" style="border: 1px solid #CCCCCC; white-space: nowrap;"><span class='priceColor2'><?php echo $this->currency->priceDisplay($this->orderDetails['details']['BT']->order_shipment_tax, $this->currency)?></span></td>
<?php } ?>
<td align="right" style="border: 1px solid #CCCCCC;"></td>
<td align="right" style="border: 1px solid #CCCCCC; white-space: nowrap;"><?php echo $this->currency->priceDisplay($this->orderDetails['details']['BT']->order_shipment + $this->orderDetails['details']['BT']->order_shipment_tax, $this->currency); ?></td>
</tr>
<tr>
<td align="right" class="pricePad" colspan="6" style="border: 1px solid #CCCCCC;"><?php echo strip_tags(str_replace('</span>', ' ', $this->orderDetails['paymentName']))?></td>
<?php if ( VmConfig::get('show_tax')) { ?>
<td align="right" style="border: 1px solid #CCCCCC; white-space: nowrap;"><span class="priceColor2"><?php echo $this->currency->priceDisplay($this->orderDetails['details']['BT']->order_payment_tax, $this->currency)?></span></td>
<?php } ?>
<td align="right" style="border: 1px solid #CCCCCC;"></td>
<td align="right" style="border: 1px solid #CCCCCC; white-space: nowrap;"><?php echo $this->currency->priceDisplay($this->orderDetails['details']['BT']->order_payment + $this->orderDetails['details']['BT']->order_payment_tax, $this->currency); ?></td>
</tr>
<tr>
<td align="right" class="pricePad" colspan="6" style="border: 1px solid #CCCCCC;"><strong><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_TOTAL')?></strong></td>
<?php if ( VmConfig::get('show_tax')) { ?>
<td align="right" style="border: 1px solid #CCCCCC; white-space: nowrap;"><span class="priceColor2"><?php echo $this->currency->priceDisplay($this->orderDetails['details']['BT']->order_billTaxAmount, $this->currency); ?></span></td>
<?php } ?>
<td align="right" style="border: 1px solid #CCCCCC; white-space: nowrap;"><span class="priceColor2"><?php echo $this->currency->priceDisplay($this->orderDetails['details']['BT']->order_billDiscountAmount, $this->currency); ?></span></td>
<td align="right" style="border: 1px solid #CCCCCC; white-space: nowrap;"><strong><?php echo $this->currency->priceDisplay($this->orderDetails['details']['BT']->order_total, $this->currency); ?></strong></td>
</tr>
<?php } ?>
<?php
if ($version >= 3010)
{
if($taxBill && VmConfig::get('show_tax'))
{
?>
<tr>
<td colspan="6" align="right" class="pricePad" style="border: 1px solid #CCCCCC; white-space: nowrap;"><?php echo vmText::_('COM_VIRTUEMART_TOTAL_INCL_TAX')?></td>
<td style="border: 1px solid #CCCCCC; white-space: nowrap;"></td>
<td style="border: 1px solid #CCCCCC; white-space: nowrap;"></td>
</tr>
<?php
foreach($taxBill as $rule){
if ($rule->calc_kind == 'taxRulesBill' or $rule->calc_kind == 'VatTax' ) { ?>
<tr >
<td colspan="6"  align="right" class="pricePad" style="border: 1px solid #CCCCCC; white-space: nowrap;"><?php echo $rule->label ?> </td>
<?php if ( VmConfig::get('show_tax')) {  ?>
<td align="right" style="border: 1px solid #CCCCCC; white-space: nowrap;"><?php echo $this->currency->priceDisplay($rule->calc_result, $this->user_currency_id); ?></td>
<?php } ?>
<td align="right" style="border: 1px solid #CCCCCC; white-space: nowrap;"></td>
<td align="right" style="border: 1px solid #CCCCCC; white-space: nowrap;"></td>
</tr>
<?php
}
}
}
}
?>
</table>
*

draff

  • Гуру
  • 5803
  • 434 / 7
  • ищу работу
Re: Производитель в инвойсе
« Ответ #11 : 02.08.2019, 10:47:23 »
У меня кастомный файл сильно отличается Вашего, видимо версия другая.
А сорри, не локалке тест сайт с Вирт актуальным 3.4
*

stepan39

  • Захожу иногда
  • 497
  • 27 / 0
Re: Производитель в инвойсе
« Ответ #12 : 03.08.2019, 03:16:50 »
Чудны дела твои, господи...
Простая конструкция помогла
Код
<?php echo $item->mf_name; ?>

Без всякого дополнительного кода. Т.е. с первого поста пошло усложнение задачи  ;D.
Всем спасибо, тема закрыта.
Чтобы оставить сообщение,
Вам необходимо Войти или Зарегистрироваться