News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Show product price list according to units

Started by cdbaron88, January 11, 2021, 14:28:01 PM

Previous topic - Next topic

cdbaron88

VirtueMart 3.8.4 10335
Joomla! 3.9.22
PHP 7.2.34
Apache/2.4.29



I am trying to show the price of the products like a list according to the units.

In the category view it is working well, but in the product view it does not work so well.

I have the server log full of these errors:
Warning: explode() expects parameter 2 to be string, array given in /home/carlos/www/jaltor.com/public_html/administrator/components/com_virtuemart/helpers/vmtable.php on line 572
Warning: Invalid argument supplied for foreach() in /home/carlos/www/jaltor.com/public_html/administrator/components/com_virtuemart/helpers/vmtable.php on line 573



How can I get the complete price list from a product view avoiding the errors in vmtable.php?

Thanks


the code on my template:

$product_model = VmModel::getModel ('product');
$product_unit = vmText::_('COM_VIRTUEMART_UNIT_SYMBOL_'.strtoupper(trim($product->product_unit)));
$first_price = TRUE;
$html_prices ='';
foreach ($product->allPrices as $prices) {
if ($first_price) {
$first_price = FALSE;
$clase_resaltar = "";
if ($prices['price_quantity_start'] == 10) {
$clase_resaltar = ' class="resaltar-pvp"';
}
$prices = $product_model->getPrice ($product->virtuemart_product_id, $prices['price_quantity_end']);
$sales_price = round($prices['salesPrice'],2);
$price_quantity_start = $prices['price_quantity_start'];
$html_prices .= "<li${clase_resaltar}>(+${price_quantity_start}${product_unit}=${sales_price}€/${product_unit})</li>";
}
}
if ($html_prices != '') {
echo '<div class="precios-por-unidades"><ul>' . $html_prices . '</ul></div>';
}





The problem is in this line:

$prices = $product_model->getPrice ($product->virtuemart_product_id, $prices['price_quantity_end']);




file administrator/components/com_virtuemart/helpers/vmtable.php

572 $params = explode('|', $obj->{$xParams});
573 foreach ($params as $item) {

$item = explode('=', $item);
$key = $item[0];
unset($item[0]);

if(isset($varsToPushParam[$key][1])) {
$item = implode('=', $item);
$item = json_decode($item);
if ($item != null){
$obj->{$key} = $item;


} else {
//vmdebug('bindParameterable $item ==null '.$key,$varsToPushParam[$key]);
}
}
//else {
// Unsolicited Parameter
//}
}

pinochico

#1
Do you mean this?

Easy table without function vmtable, without plugin, only 50 lines in PHP
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

jenkinhill

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

cdbaron88

What I have made is a price table similar to the one shown by @pinochito showing the final price of the product according to the units purchased.

Many customers are buying from the category view without going to see the detail of the product, so I want to view the price table both in detail of the product and in the category view.

I attach 2 images, 1 is working fine, 2 I have errors in the vmtable function.


I want to use the Virtuemart API functions if possible to avoid problems in the future. Also I am not very expert in PHP and I do not know very well how to make direct queries to the database.

thanks for the suggestion @jenkinhill, I've been looking at the "Quantity related price calculation" module, but the demo is a bit poor and it doesn't seem like you can put the price table directly in the category view.

T.A. Garrison, LLC

I'm hoping to get more information on this. Hopefully pinochico will have the answer and respond.

I'm sure it's simple, but the code is outside of my expertise.

I "have" the iStraxx plugin to which Jenkinhill referred.
I've gone through every setting, even switched the "New" VM admin template off so the bug in that template would allow me to use "all" of VM instead of only most. But I cannot get the table to display. All of the functions work perfectly, meaning, the discounts are applied, but the user can only see the discounts once the product is added to the cart. There is nothing in the product details that indicates the user is getting a discount. The price doesn't change when selecting the quantity that changes the price, unless you do that in the cart.

After a month with no word from iStraxx I've been trying to get help from "anybody" who can make the iStraxx work or create another that does actually display the table discount list in the products. I've even solicited a couple of developers and still, I'm not getting anywhere.

Pinochico, if you can help with this it would be great!

I'm at a stand-still because unless I can get this to function as designed, I have to "figure out" some method that will work for the same thing and we have hundreds of thousands of products and children. So creating a quantity price change in every single child for every single option a user selects it simply not going to work.

I know there is code in the iStraxx plugin that is deprecated, but I have no idea of that's the problem. I only know that the vmtable does "not" display.

Any thoughts?
T.A. Garrison, LLC
3150 Orleans St. # 28261
Bellingham, WA 98228