Skip to main content

Module to show product price

More
7 years 2 months ago #309073 by fernandoIncerco
-- url of the page with the problem -- : www.incerco.es/puerta-seguridad-top-door...roduct/sheet-pizarra
-- HikaShop version -- : 4.1
-- Joomla version -- : 3.9

Hello,
I am developing a simple custom module to show product price wherever I want. The problem is that I can't achive the price with options...
I tried with this code:
Code:
if(!defined('DS')) define('DS', DIRECTORY_SEPARATOR); if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')){ echo 'This module can not work without the Hikashop Component'; return true; }; //get product id $product_id = (int)hikashop_getCID('product_id'); if(empty($product_id )) return true; // load product $productClass = hikashop_get('class.product'); $product = $productClass->get($product_id); if(empty($product )) return true; //load prices $currencyClass = hikashop_get('class.currency'); $config = hikashop_config(); $ids = array($product_id); $currencyClass->getPrices($product,$ids,hikashop_getCurrency(),(int)$config->get('main_currency',1), hikashop_getZone(null),(int)$config->get('discount_before_tax',0)); // display the first price of the product echo $product->prices[0]->price_value;

Thanks

Please Log in or Create an account to join the conversation.

More
7 years 2 months ago #309074 by nicolas
Hi,

If you want to display the price with options elsewhere, you just need to move the tag
Code:
<span id="hikashop_product_price_with_options_main" class="hikashop_product_price_with_options_main"></span>
from your product page main layout to where you want it. As long as it's on the product page, the javascript of the options system will fill it with the price.
The following user(s) said Thank You: fernandoIncerco

Please Log in or Create an account to join the conversation.

More
7 years 2 months ago #309111 by fernandoIncerco
I tried this option but if I put this code twice in the show_default view, the firs one is ok but the second instance is blank :(
I want to pt the price at the top of the page and again at the bottom.

Please Log in or Create an account to join the conversation.

More
7 years 2 months ago #309121 by nicolas
Hi,

In that case, I would recommend to put the second one with a different id and then simply change the javascript code in the option.php view file to also update that second span:
Code:
var target = d.getElementById("hikashop_product_price_with_options_main"); if(target) o.xRequest("'.hikashop_completeLink('product&task=price'.$url_itemid,true,true).'", {mode:"POST",data:"price="+price_with_options.value,update:target});

Please Log in or Create an account to join the conversation.

More
7 years 2 months ago #309145 by fernandoIncerco
This works perfect for me!!
Thanks

Please Log in or Create an account to join the conversation.

Time to create page: 0.157 seconds
Powered by Kunena Forum