VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: Master_gray on July 29, 2013, 18:54:19 PM

Title: How do i grab the cart data?
Post by: Master_gray on July 29, 2013, 18:54:19 PM
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.
Title: Re: How do i grab the cart data?
Post by: Maxim Pishnyak on July 29, 2013, 19:44:13 PM
Just curious, what is your goal?
Title: Re: How do i grab the cart data?
Post by: Master_gray on July 29, 2013, 20:45:12 PM
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.
Title: Re: How do i grab the cart data?
Post by: Maxim Pishnyak on July 30, 2013, 20:59:44 PM
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?
Title: Re: How do i grab the cart data?
Post by: Master_gray on July 30, 2013, 21:15:03 PM
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.
Title: Re: How do i grab the cart data?
Post by: Maxim Pishnyak on July 30, 2013, 21:49:55 PM
Attach to your next post php file where you have these rows.
Title: Re: How do i grab the cart data?
Post by: Master_gray on July 30, 2013, 22:14:31 PM
Sorry i don't know what you mean?
Title: Re: How do i grab the cart data?
Post by: Maxim Pishnyak on July 31, 2013, 10:37:37 AM
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.
Title: Re: How do i grab the cart data?
Post by: Master_gray on July 31, 2013, 11:35:25 AM
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.