I need get parts of [product_attribute]
Of this attribute, I just need visible the (deliverydate) and (enddate)
[product_attribute] => { "102": { "10119": { "type": "rent", "deliverydate": "28\/06\/2019", "enddate": "30\/06\/2019" } } } [order_status] => F [intnotes] => [virtuemart_category_id] => 2 [virtuemart_manufacturer_id] => Array (
Use php function json_decode to get Your attributes.
Jörgen @ Kreativ Fotografi
Hi, sorry, got it not.
I can take the values that way;
Alugando por 3 Dia(s), de 25/05/2019 até 27/05/2019: R$ 15,00 (I do not need to bring the value)
---
foreach($this->orderDetails['items'] as $item) {
$product_attribute = VirtueMartModelCustomfields::CustomsFieldOrderDisplay($item,'FE');
echo $product_attribute;}
You need to write your own plugin "rent", so you can customize the display in order, cart, product details... and more
I already have this plugin
Depending the view, you have this functions in your plugin to modify
function plgVmOnViewCartVM3(&$product, &$group, &$html) {
}
function plgVmOnViewCartModuleVM3( &$product, &$group, &$html) {
}
function plgVmDisplayInOrderBEVM3( &$product, &$group, &$html) {
}
function plgVmDisplayInOrderFEVM3(&$product, &$group, &$html) {
}
Yes, have all
--
function plgVmOnViewCartModuleVM3(&$product, &$pc, &$html) {
if (empty($pc->custom_element) or $pc->custom_element != $this->_name) return false;
if (empty($product->customProductData[$pc->virtuemart_custom_id][$pc->virtuemart_customfield_id])) return false;
$this->parseRentCustomParams($pc);
$items = $product->customProductData[$pc->virtuemart_custom_id];
foreach ($items as $k =>$item) {
if($pc->virtuemart_customfield_id == $k and JArrayHelper :: getValue($item, 'type') != 'purchase'
and $deliverydate = $this->decodeDate(JArrayHelper :: getValue($item, 'deliverydate'), $pc)
and $enddate = $this->decodeDate(JArrayHelper :: getValue($item, 'enddate'), $pc)) {
$this->_loadLanguageFile();
$rent_days = floor((strtotime($enddate) - strtotime($deliverydate))/86400) + 1;
if ($rent_days > 0) {
$html .= '<div>';
$html .= JText :: sprintf('PLG_FWVMR_RENT_FOR_DAYS', $rent_days, $this->encodeDate($deliverydate, $pc), $this->encodeDate($enddate, $pc));
$html .= '</div>';
}
}
}
return true;
}
function plgVmOnViewCartVM3(&$product, &$pc, &$html) {
if (empty($pc->custom_element) or $pc->custom_element != $this->_name) return false;
if (empty($product->customProductData[$pc->virtuemart_custom_id][$pc->virtuemart_customfield_id])) return false;
$this->parseRentCustomParams($pc);
$items = $product->customProductData[$pc->virtuemart_custom_id];
foreach ($items as $k =>$item ) {
if ($pc->virtuemart_customfield_id == $k and JArrayHelper :: getValue($item, 'type') != 'purchase'
and $deliverydate = $this->decodeDate(JArrayHelper :: getValue($item, 'deliverydate'), $pc)
and $enddate = $this->decodeDate(JArrayHelper :: getValue($item, 'enddate'), $pc)) {
$this->_loadLanguageFile();
require_once(JPATH_ADMINISTRATOR.'/components/com_virtuemart/helpers/currencydisplay.php');
$currency = CurrencyDisplay::getInstance();
$rent_days = floor((strtotime($enddate) - strtotime($deliverydate))/86400) + 1;
$per_period = (!empty($pc->price_per) and $pc->price_per == 'period');
if (!empty($pc->count_first_day)) {
$rent_days--;
}
if ($rent_days > 0) {
$price = 0;
if (!empty($pc->rent_sizes)) foreach ($pc->rent_sizes as $i => $rent) {
if (!empty($rent->rent_show) and $rent_days >= $rent->rent_start and $rent_days <= $rent->rent_end) {
if ($per_period) {
$price = $rent->rent_product_price;
} else {
$price = $rent->rent_product_price * $rent_days;
}
break;
}
}
$html .= JText :: sprintf('PLG_FWVMR_RENT_FOR_DAYS', $rent_days, $this->encodeDate($deliverydate, $pc), $this->encodeDate($enddate, $pc)).': '.$currency->getSymbol().' '.number_format($price * $product->quantity, 2, ",", ".").'<br/>';
if ($pc->rent_product_deposit > 0) $html .= JText :: sprintf('PLG_FWVMR_INCLUDING_DEPOSIT').': '.$currency->getSymbol().' '.number_format($pc->rent_product_deposit * $product->quantity, 2, ",", ".").'<br/>';
if (JArrayHelper :: getValue($item, 'insurance_option')) $html .= JText :: sprintf('PLG_FWVMR_INCLUDING_INSURANCE').': '.$currency->getSymbol().' '.number_format($pc->rent_product_insurance * $product->quantity, 2, ",", ".");
}
}
}
return true;
}
function plgVmDisplayInOrderBEVM3( &$product, &$pc, &$html) {
$this->plgVmDisplayInOrderFEVM3($product,$pc,$html);
}
function plgVmDisplayInOrderFEVM3( &$product, &$pc, &$html) {
if (empty($pc->custom_element) or $pc->custom_element != $this->_name) return false;
if (empty($product->customProductData[$pc->virtuemart_custom_id][$pc->virtuemart_customfield_id])) return false;
$this->parseRentCustomParams($pc);
$items = $product->customProductData[$pc->virtuemart_custom_id];
foreach ($items as $k =>$item ) {
if($pc->virtuemart_customfield_id == $k and JArrayHelper :: getValue($item, 'type') != 'purchase'
and $deliverydate = $this->decodeDate(JArrayHelper :: getValue($item, 'deliverydate'), $pc)
and $enddate = $this->decodeDate(JArrayHelper :: getValue($item, 'enddate'), $pc)) {
$this->_loadLanguageFile();
require_once(JPATH_ADMINISTRATOR.'/components/com_virtuemart/helpers/currencydisplay.php');
$currency = CurrencyDisplay::getInstance();
$rent_days = floor((strtotime($enddate) - strtotime($deliverydate))/86400) + 1;
if ($rent_days > 0) {
$price = $product->product_item_price - (($pc->rent_product_deposit > 0)?$pc->rent_product_deposit:0) - (JArrayHelper :: getValue($item, 'insurance_option')?$pc->rent_product_insurance:0);
$html .= JText :: sprintf('PLG_FWVMR_RENT_FOR_DAYS', $rent_days, $this->encodeDate($deliverydate, $pc), $this->encodeDate($enddate, $pc)).': '.$currency->getSymbol().' '.number_format($price * $product->product_quantity, 2, ",", ".").'<br/>';
if ($pc->rent_product_deposit > 0) $html .= JText :: sprintf('PLG_FWVMR_INCLUDING_DEPOSIT').': '.$currency->getSymbol().' '.number_format($pc->rent_product_deposit * $product->product_quantity, 2, ",", ".").'<br/>';
if (JArrayHelper :: getValue($item, 'insurance_option')) $html .= JText :: sprintf('PLG_FWVMR_INCLUDING_INSURANCE').': '.$currency->getSymbol().' '.number_format($pc->rent_product_insurance * $product->product_quantity, 2, ",", ".");
}
}
}
return true;
}
The code already extract it and display it formated.
So check the right function and modify the render
$html return the display inside the order and cart