VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: baoquocmt159 on March 27, 2015, 09:34:40 AM

Title: Get cart session and change price
Post by: baoquocmt159 on March 27, 2015, 09:34:40 AM
Hi all,

I have develop an system plugin, and on the cart page, i have options, how to i can get cart session and change the Total price when i choose options.

Thank so much !
Title: Re: Get cart session and change price
Post by: Milbo on March 27, 2015, 09:53:45 AM
check the textinputplugin.
Title: Re: Get cart session and change price
Post by: baoquocmt159 on March 27, 2015, 10:10:43 AM
Quote from: Milbo on March 27, 2015, 09:53:45 AM
check the textinputplugin.

Hi Milbo,

I did checked but that's vmcustom plugin so i can't get anything.
Also i have tried with code :



if (!class_exists( 'VmConfig' )) require(JPATH_ADMINISTRATOR . '/components/com_virtuemart/helpers/config.php');
VmConfig::loadConfig();
if(!class_exists('VirtueMartCart')) require(JPATH_VM_SITE.DS.'helpers'.DS.'cart.php');
$cart = VirtueMartCart::getCart();

$cart->cartPrices['billTotal'] = $cart->cartPrices['billTotal']+10;


But it's still nothing change.

I think i did wrong. Do you have solution?

Thank you so much !
Title: Re: Get cart session and change price
Post by: PRO on March 27, 2015, 14:46:52 PM
are you using system plugin?

or virtuemart custom plugin?

what version are you using?

Title: Re: Get cart session and change price
Post by: baoquocmt159 on March 27, 2015, 15:10:04 PM
Quote from: PRO on March 27, 2015, 14:46:52 PM
are you using system plugin?

or virtuemart custom plugin?

what version are you using?



Hi PRO,

Yes i used system plugin, and VM 3.0.6 version, joomla 3.4

Thank you so much !
Title: Re: Get cart session and change price
Post by: PRO on March 27, 2015, 18:40:17 PM
why not a virtuemart custom plugin?

WHAT IS IT SUPPOSED TO DO?
Title: Re: Get cart session and change price
Post by: baoquocmt159 on March 28, 2015, 04:25:28 AM
Quote from: PRO on March 27, 2015, 18:40:17 PM
why not a virtuemart custom plugin?

WHAT IS IT SUPPOSED TO DO?

Hi PRO,

Because i want choose options on the cart page, not productdetail page. Please help me.
@Milbo

Thank you so much !
Title: Re: Get cart session and change price
Post by: baoquocmt159 on March 30, 2015, 05:54:59 AM
Hello @Milbo, Hello @PRO

How are you?
Title: Re: Get cart session and change price
Post by: baoquocmt159 on March 30, 2015, 11:12:56 AM
Hello

I have tried :


$data = $this->cart->prepareAjaxData(FALSE);
$prices = $this->getCartPrices();
$prices["billTotal"] += 10;
$this->cart->setCartIntoSession();


But still can't save new price :(

Can someone help me?

Thank a lot !
Title: Re: Get cart session and change price
Post by: PRO on March 30, 2015, 11:46:50 AM
baoquocmt159,

describe what your plugin does.

what is the option for?

Title: Re: Get cart session and change price
Post by: baoquocmt159 on March 30, 2015, 16:50:15 PM
Quote from: PRO on March 30, 2015, 11:46:50 AM
baoquocmt159,

describe what your plugin does.

what is the option for?



Hi PRO,

I have a <select .. option>, when i select option, i use jQuery ajax to php file, in this php file, i want $prices["billTotal"] add 10 (for example), and i did used code :


// load VM config, VM helper cart here.
$data = $this->cart->prepareAjaxData(FALSE);
$prices = $this->getCartPrices();
$prices["billTotal"] += 10;
$this->cart->setCartIntoSession();


But it's still notchange :(

Thank a lot !
Title: Re: Get cart session and change price
Post by: PRO on March 31, 2015, 14:05:58 PM
I am not sure how to help with a system plugin.

does this have to do with shipping etc?

Because i know this could easily be done with a shipping plugin

Title: Re: Get cart session and change price
Post by: Milbo on April 02, 2015, 09:28:47 AM
baoquocmt159 your way would be very unsecure.What you try does not work in VM. VM recognises it as illegal data manipulation and sets the correct values
Title: Re: Get cart session and change price
Post by: baoquocmt159 on April 06, 2015, 08:52:09 AM
Hi Milbo, PRO

I did solved by myself.

Thanks
Title: Re: Get cart session and change price
Post by: likrish on September 24, 2015, 00:05:09 AM
Hi, I know this is a dead thread, however I am looking at the same problems myself and was wondering if you could let me know how you solved the issue, or perhaps let me have a copy of your plugin  :)

Dean
Skype: Datalynk
Title: Re: Get cart session and change price
Post by: Milbo on September 24, 2015, 10:07:09 AM
Quote from: baoquocmt159 on March 28, 2015, 04:25:28 AM
Because i want choose options on the cart page, not productdetail page. Please help me.

You still need a vm plugin and you still must use the trigger used in the customplugins to change the price. By security reasons it does NOT work to change the price in the session, it would be corrected by the system. You MUST use a correct plugin and it is nonsens to write a joomla plugin, if we have already a pattern for it.
Title: Re: Get cart session and change price
Post by: Milbo on September 24, 2015, 10:08:38 AM
Quote from: Datalynk on September 24, 2015, 00:05:09 AM
Hi, I know this is a dead thread, however I am looking at the same problems myself and was wondering if you could let me know how you solved the issue, or perhaps let me have a copy of your plugin  :)

Dean
Skype: Datalynk

yeh that would be indeed interesting.
Title: Re: Get cart session and change price
Post by: likrish on September 24, 2015, 15:49:17 PM
I understand that a properly constructed plugin IS the way forward, however I would like to know which of the available types of VM plugin is most suited to this task (i.e. vmcalculation or vmcustomfield etc...).
Title: Re: Get cart session and change price
Post by: Milbo on September 24, 2015, 21:54:02 PM
vmcustom

check the textinput plugin and the function plgVmPrepareCartProduct
Title: Re: Get cart session and change price
Post by: PRO on September 25, 2015, 14:33:44 PM
Quote from: Datalynk on September 24, 2015, 15:49:17 PM
I understand that a properly constructed plugin IS the way forward, however I would like to know which of the available types of VM plugin is most suited to this task (i.e. vmcalculation or vmcustomfield etc...).

vm custom field

Title: Re: Get cart session and change price
Post by: likrish on September 25, 2015, 17:34:56 PM
Thank you Milbo, I have found what I need in the textinput plugin to override product price...