News:

Support the VirtueMart project and become a member

Main Menu

How do i grab the cart data?

Started by Master_gray, July 29, 2013, 18:54:19 PM

Previous topic - Next topic

Master_gray

Hi everyone,

i'm trying to grab the cart data but i'm getting the wrong out put,the below php i got online,

My problem is i need the price to be separated from each other (100,46,503..etc) but the below code adds it all to one sum,how can i separate them?

$array = unserialize($_SESSION['__vm']['vmcart']);
    $amount = 0;
    foreach($array->products as $product){
            $amount += $product->product_price;
    }
    echo $amount;


Thanks for the help.

Maxim Pishnyak

Just curious, what is your goal?
You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart

Master_gray

#2
Hi there,

This is a post i made explaining everything it need to do and what it is,
https://forum.virtuemart.net/index.php?topic=116943.msg394590#msg394590

Thanks.

Maxim Pishnyak

Quote from: Master_gray on July 29, 2013, 18:54:19 PM
My problem is i need the price to be separated from each other (100,46,503..etc) but the below code adds it all to one sum,how can i separate them?
Don't understand you clearly. What do you mean when you say "separated"? What end result of separating do you wish?
You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart

Master_gray

Hi Maxim,

it's currently displaying like this:

461 (all together)

i need it to show like this:

200
240
21

each products price separate from each other and not combined in a total.
Thanks.

Maxim Pishnyak

Attach to your next post php file where you have these rows.
You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart

Master_gray

Sorry i don't know what you mean?

Maxim Pishnyak

Quote from: Master_gray on July 29, 2013, 18:54:19 PM
$array = unserialize($_SESSION['__vm']['vmcart']);
    $amount = 0;
    foreach($array->products as $product){
            $amount += $product->product_price;
    }
    echo $amount;

I need full source from which you took that part.
You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart

Master_gray

Hi Maxim,

i found the solution here :(i don't know if i my link to another forum if not sorry)
http://stackoverflow.com/questions/15006030/display-the-number-of-items-in-the-cart-on-virtuemart-joomla-2-5

as you can see the code i posted is below the solution - Thanks for your time  :)  if i have any problems i will post again.