- Posts: 26
- Thank you received: 1
Module to show product price
- fernandoIncerco
-
Topic Author
- Offline
Less
More
7 years 2 months ago #309073
by fernandoIncerco
Module to show product price was created 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:
Thanks
-- 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.
7 years 2 months ago #309074
by nicolas
Replied by nicolas on topic Module to show product price
Hi,
If you want to display the price with options elsewhere, you just need to move the tag
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.
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>
The following user(s) said Thank You: fernandoIncerco
Please Log in or Create an account to join the conversation.
- fernandoIncerco
-
Topic Author
- Offline
Less
More
- Posts: 26
- Thank you received: 1
7 years 2 months ago #309111
by fernandoIncerco
Replied by fernandoIncerco on topic Module to show product price
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.
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.
7 years 2 months ago #309121
by nicolas
Replied by nicolas on topic Module to show product price
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:
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.
- fernandoIncerco
-
Topic Author
- Offline
Less
More
- Posts: 26
- Thank you received: 1
7 years 2 months ago #309145
by fernandoIncerco
Replied by fernandoIncerco on topic Module to show product price
This works perfect for me!!
Thanks
Thanks
Please Log in or Create an account to join the conversation.
Time to create page: 0.169 seconds