VirtueMart Forum

VirtueMart 2 + 3 => 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
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 :

Code: [Select]

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
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
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 :

Code: [Select]
$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
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 :

Code: [Select]
// 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: 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
Title: Re: Get cart session and change price
Post by: Milbo on September 24, 2015, 10:07:09 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
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: 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...).
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
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: Datalynk 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...