Author Topic: Get cart session and change price  (Read 4604 times)

baoquocmt159

  • Jr. Member
  • **
  • Posts: 57
  • Skype Name: cpo.smartbits
Get cart session and change price
« 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 !

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9919
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Get cart session and change price
« Reply #1 on: March 27, 2015, 09:53:45 am »
check the textinputplugin.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

baoquocmt159

  • Jr. Member
  • **
  • Posts: 57
  • Skype Name: cpo.smartbits
Re: Get cart session and change price
« Reply #2 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 !

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10358
  • VirtueMart Version: 3+
Re: Get cart session and change price
« Reply #3 on: March 27, 2015, 14:46:52 pm »
are you using system plugin?

or virtuemart custom plugin?

what version are you using?

J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

baoquocmt159

  • Jr. Member
  • **
  • Posts: 57
  • Skype Name: cpo.smartbits
Re: Get cart session and change price
« Reply #4 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 !

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10358
  • VirtueMart Version: 3+
Re: Get cart session and change price
« Reply #5 on: March 27, 2015, 18:40:17 pm »
why not a virtuemart custom plugin?

WHAT IS IT SUPPOSED TO DO?
J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

baoquocmt159

  • Jr. Member
  • **
  • Posts: 57
  • Skype Name: cpo.smartbits
Re: Get cart session and change price
« Reply #6 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 !

baoquocmt159

  • Jr. Member
  • **
  • Posts: 57
  • Skype Name: cpo.smartbits
Re: Get cart session and change price
« Reply #7 on: March 30, 2015, 05:54:59 am »
Hello @Milbo, Hello @PRO

How are you?

baoquocmt159

  • Jr. Member
  • **
  • Posts: 57
  • Skype Name: cpo.smartbits
Re: Get cart session and change price
« Reply #8 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 !

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10358
  • VirtueMart Version: 3+
Re: Get cart session and change price
« Reply #9 on: March 30, 2015, 11:46:50 am »
baoquocmt159,

describe what your plugin does.

what is the option for?

J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

baoquocmt159

  • Jr. Member
  • **
  • Posts: 57
  • Skype Name: cpo.smartbits
Re: Get cart session and change price
« Reply #10 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 !

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10358
  • VirtueMart Version: 3+
Re: Get cart session and change price
« Reply #11 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

J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9919
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Get cart session and change price
« Reply #12 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
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

baoquocmt159

  • Jr. Member
  • **
  • Posts: 57
  • Skype Name: cpo.smartbits
Re: Get cart session and change price
« Reply #13 on: April 06, 2015, 08:52:09 am »
Hi Milbo, PRO

I did solved by myself.

Thanks

Datalynk

  • Beginner
  • *
  • Posts: 23
  • Innovative & Ground Breaking Solutions
    • Datalynk UK | Website Design and Development
  • Skype Name: Datalynk
  • VirtueMart Version: 2.6.6
Re: Get cart session and change price
« Reply #14 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
Dean
Senior Development Consultant
Datalynk UK