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

change country id in Cart data from productdetailsview

Started by Peter Pillen, June 07, 2014, 17:14:57 PM

Previous topic - Next topic

Peter Pillen

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);


Milbo

   $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.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Peter Pillen

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 ;)