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

"if" product havent children

Started by marvays, December 16, 2019, 15:09:47 PM

Previous topic - Next topic

marvays

Hi again.
I try change template. I need hide div#productPrice for parent product with with children.

In code i see
if ($this->product->prices['salesPrice'] > 0) {
  echo shopFunctionsF::renderVmSubLayout('snippets',array('product'=>$this->product, 'currency'=>$this->currency, 'showRating'=>$this->showRating));
}


How i can change "if" to "when product have children"?

I try

if ($this->product->children != 0) {
  echo shopFunctionsF::renderVmSubLayout('snippets',array('product'=>$this->product, 'currency'=>$this->currency, 'showRating'=>$this->showRating));
}


but no work.

PRO

function hasChilds($pid){
$productModel = VmModel::getModel('product');
$ids = $productModel->getProductChildIds($pid);
if (!empty($ids)){
return 1;
}
}

if (hasChilds($this->product->virtuemart_product_id)==1){
  echo shopFunctionsF::renderVmSubLayout('snippets',array('product'=>$this->product, 'currency'=>$this->currency, 'showRating'=>$this->showRating));
}


///////////////////////////////

&&& for anyone that wants to check if a product is a child

function hasParent($pid){
$productModel = VmModel::getModel('product');
$id = $productModel->getProductParentId($pid);
if (!empty($id)){
return 1;
}
}

marvays

Thank you very much for your help.
In my case . . . If I want to keep the price with my parents and only show it to their offspring, this works:

function hasChilds($pid){
$productModel = VmModel::getModel('product');
$ids = $productModel->getProductChildIds($pid);
if (!empty($ids)){
return 1;
}
}

if (hasChilds($this->product->virtuemart_product_id)!=1){
  echo shopFunctionsF::renderVmSubLayout('prices',array('product'=>$this->product,'currency'=>$this->currency));
}

pinochico

Our customers want to see the price immediately when the product (== parent) is displayed on the category or detail and not be obliged to select the child to display the price.
As soon as I force them to choose a child, they leave because they don't care.

You are also breaking the details of the product and Google will mark the parent page as faulty and will not include it in the index. Is it really the right way?
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

marvays

faulty because the site has no selling price? Ideally, I would only index children. The parent is only a signpost.

PRO

I do a price table on parent.

function price_table($pid){
$productModel = VmModel::getModel('product');
$ids = $productModel->getProductChildIds($pid);
$prods = $productModel->getProducts($ids);
$customfieldsModel = VmModel::getModel ('Customfields');
$prods->customfields = $customfieldsModel->getCustomEmbeddedProductCustomFields ($product->allIds,0,-1, true);
$html='';
if (!empty($prods)){
$prices=Array();
foreach ($prods as $p){
$prices[]=$p->prices['salesPrice'];
}
if (count($prices>1)){
$html.='<p class="redtext bold">Price from $'.min($prices).' - $'.max($prices).'</p>';
$html.='<p class="greentext">Choose Options to See Price</p>';
}

}

echo $html;
}



echo price_table($this->product->virtuemart_product_id);


marvays

#6
Nice, this work.
But, where I can change prize. I see "26230.0049 - 27980.0037", and need "26 230,- Kč - 27 980,- Kč"
https://novy.azttrade.eu/index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=1538&virtuemart_category_id=23&lang=cs

razor7

Quote from: PRO on December 16, 2019, 19:36:42 PM
function hasChilds($pid){
$productModel = VmModel::getModel('product');
$ids = $productModel->getProductChildIds($pid);
if (!empty($ids)){
return 1;
}
}

if (hasChilds($this->product->virtuemart_product_id)==1){
  echo shopFunctionsF::renderVmSubLayout('snippets',array('product'=>$this->product, 'currency'=>$this->currency, 'showRating'=>$this->showRating));
}


///////////////////////////////

&&& for anyone that wants to check if a product is a child

function hasParent($pid){
$productModel = VmModel::getModel('product');
$id = $productModel->getProductParentId($pid);
if (!empty($id)){
return 1;
}
}

Cool! that's what I was looking for! thanks!
MGS Creativa - VirtueMart Payment Plugin Experts
http://www.mgscreativa.com

Take a look at our downloads section for VirtueMart payment plugins and mouch more!
http://www.mgscreativa.com/en/online-store