VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: Peter Pillen on June 07, 2014, 17:14:57 PM

Title: change country id in Cart data from productdetailsview
Post by: Peter Pillen on June 07, 2014, 17:14:57 PM
Hello,

Just a short explanation of what i'm trying to do. In the productdetailsview there is a dropdown with all the active countries in VM. When a visitor is looking at a product I would like them to have the option to select a country from the dropdown and see which shipmentmethods are available for that country. I used the country id stored in the Cart session data ...

   $CartData = VirtueMartCart::getCart();
   $CartCountryid=$CartData->BT['virtuemart_country_id'];

If no country is stored in the Cart, I use my own country by default. But if a user selects another country in this dropdown from productdetails view I would like to update the country id that is stored in de cart session data. So in short ... How to change the country id stored in the cart? How is the session code written to change the value?

... the following code is noob-code to clarify what i'm looking for ...

   $CartData = VirtueMartCart::getCart();
   $Cart=$Cart->set(BT['virtuemart_country_id'], $newvalue);
Title: Re: change country id in Cart data from productdetailsview
Post by: Peter Pillen on June 18, 2014, 08:18:13 AM
*bump*
Title: Re: change country id in Cart data from productdetailsview
Post by: Milbo on June 18, 2014, 09:31:54 AM
   $CartData = VirtueMartCart::getCart(); NEVER WRITE THIS! The cartobject has a property named cartData.

$cart = VirtueMartCart::getCart();
$cart->BT['virtuemart_country_id'] = $myID;
$cart->setCartIntoSession();

But actually, you are going the wrong way. and you should buy the supporter membership, because part of the "value added" is an enhanced shipment plugin, which shows directly in the productdetails the price of hte shipment and the delivery country. We have also another product "vmlocalise" setting the country id of your guest.
Title: Re: change country id in Cart data from productdetailsview
Post by: Peter Pillen on June 19, 2014, 08:18:30 AM
Thanks Milbo!

I probably missed the news that virtuemart now has a supporter membership. I will certainly look into that. It's a good thing that you finally will gain some money with this project ;)