Author Topic: parts of [product_attribute]  (Read 697 times)

acooper

  • Beginner
  • *
  • Posts: 11
parts of [product_attribute]
« on: June 01, 2019, 08:19:55 am »
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 (
  • => 1 )

Jörgen

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 2769
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
Re: parts of [product_attribute]
« Reply #1 on: June 01, 2019, 09:16:43 am »
Use php function json_decode to get Your attributes.

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)

acooper

  • Beginner
  • *
  • Posts: 11
Re: parts of [product_attribute]
« Reply #2 on: June 01, 2019, 15:15:11 pm »
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;}

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4336
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: parts of [product_attribute]
« Reply #3 on: June 01, 2019, 15:23:08 pm »
You need to write your own plugin "rent", so you can customize the display in order, cart, product details... and more

acooper

  • Beginner
  • *
  • Posts: 11
Re: parts of [product_attribute]
« Reply #4 on: June 01, 2019, 17:28:31 pm »
I already have this plugin

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4336
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: parts of [product_attribute]
« Reply #5 on: June 02, 2019, 00:39:50 am »
Depending the view, you have this functions in your plugin to modify
Code: [Select]
   function plgVmOnViewCartVM3(&$product, &$group, &$html) {
   }

   function plgVmOnViewCartModuleVM3( &$product, &$group, &$html) {
   }

   function plgVmDisplayInOrderBEVM3( &$product, &$group, &$html) {
   }

   function plgVmDisplayInOrderFEVM3(&$product, &$group, &$html) {
   }

acooper

  • Beginner
  • *
  • Posts: 11
Re: parts of [product_attribute]
« Reply #6 on: June 02, 2019, 05:06:54 am »
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;
    }

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4336
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: parts of [product_attribute]
« Reply #7 on: June 02, 2019, 14:45:28 pm »
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