VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product pricing => Topic started by: cygan89 on June 27, 2018, 12:03:30 PM

Title: Price List of available shipments in product page.
Post by: cygan89 on June 27, 2018, 12:03:30 PM
Hello, i dont find answer in other post's.
VM: 3.2.14
J: 3.6.5
demo link: http://test.ccy.pl/en/sklep/wszystkie-produkty/interfejsy-lpg/adapter-for-stefanelli-sis-plus-detail

I prepared list of shipments ways with pirces gemerated from published shipments:
(https://image.ibb.co/eMHF4o/2018_06_27_11_53_26_LPG_Interfaces_Adapter_for_Stefanelli_SIS_PLUS.png)

but when i change currency prices of shipment not calculating

(https://image.ibb.co/cKcbAT/2018_06_27_11_55_15_LPG_Interfaces_Adapter_for_Stefanelli_SIS_PLUS.png)

my code:


$methods = VmModel::getModel('Shipmentmethod') -> getShipments();
foreach ($methods as $item) {
if ($item -> published == 1) {
$shipment_parms = $item -> shipment_params;
$just_price = explode('|', $shipment_parms);
$float_price = round(preg_replace('/[^0-9.]/', '', $just_price[14]) * 1.23, 2);
if ($float_price < 40)
echo '<span>' . $item -> shipment_name . '</span>' . '<span style="float:right">' . number_format($float_price, 2) . ' ' . $displayCurrency -> currency_symbol . '</span>
<br> ';
}


please help
Title: Re: Price List of available shipments in product page.
Post by: Jörgen on June 27, 2018, 13:25:07 PM
You have to calculate the price with currency, look at prices.php to get some ideas.

regards

Jörgen @ Kreativ Fotografi
Title: Re: Price List of available shipments in product page.
Post by: cygan89 on June 27, 2018, 13:59:26 PM
Thanks for reply!

i think i should use function:
public function createPriceDiv($name,$description,$product_price,$priceOnly=false,$switchSequel=false,$quantity = 1.0,$forceNoLabel=false, $force = false)

sorry but im java programmer and i dont know syntax of php, if you can please tell me how to use method from  currencydisplay.php file in
/components/com_virtuemart/sublayouts/addtocart.php file

Title: Re: Price List of available shipments in product page.
Post by: Jörgen on June 27, 2018, 14:47:42 PM
Try this:

$currency = $viewData['currency'];

Jörgen @ Kreativ Fotografi
Title: Re: Price List of available shipments in product page.
Post by: cygan89 on June 27, 2018, 15:04:38 PM
i have this error
Fatal error: Call to a member function createPriceDiv() on a non-object in /home/scalp/public_html/test/components/com_virtuemart/sublayouts/addtocart.php on line 68
Title: Re: Price List of available shipments in product page.
Post by: Jörgen on June 27, 2018, 21:26:02 PM
OK the viewdata don´t include the currency, then add this to the call of the sublayout. Check the call to prices.php sublayout and do the same.

regards

Jörgen @ Kreativ Fotografi
Title: Re: Price List of available shipments in product page.
Post by: cygan89 on June 29, 2018, 15:21:35 PM
Thanks for trying help but i still can't do it...  ???
Title: Re: Price List of available shipments in product page.
Post by: Studio 42 on June 30, 2018, 01:32:36 AM
include
if (!class_exists ('CurrencyDisplay')) {
require(VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php');
}
$currency = CurrencyDisplay::getInstance();

And after use it with
$currency->priceDisplay($YOURPRICE);
Title: Re: Price List of available shipments in product page.
Post by: cygan89 on July 02, 2018, 07:50:05 AM
Thanks! WORKING !!! :)