Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Values when product add to shopping cart


drferrari

Recommended Posts

Hello,

 

In product_info.php page ONLY when I click on ad to cart button I wanna see in shopping_cart.php page, and ONLY THE LAST product id product name, product quantity, price, product category.

 

I thinking something in application_top.php in case 'add_product' : when redirect apply: tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));

 

any idea how can this work...

Link to comment
Share on other sites

in application_top.php (case 'add_product') I insert values to redirect url

 

tep_redirect(tep_href_link($goto, 'prid='.$_POST['products_id'] . '&quantity=' . $_POST['cart_quantity']));

 

and then in shopping_cart.php page I get this values.

 

IS POSIBLE on some way hide this values and then get it in shopping_cart.php page.

Link to comment
Share on other sites

when you add product to shopping cart, it adds pid to session, so, you can get last product array by $cart->get_products(true)[count($cart->get_products(true))-1]

Link to comment
Share on other sites

$cart->get_products(true) - shows array with products, added to shopping cart. this is function get_products from class includes/classes/shopping_cart.php

this array is sorted from older to newer item, added to cart. so, last added item to cart its last element of array $cart->get_products(true)

to get last element of array, we use "count($some_array)-1", in our case its count($cart->get_products(true))-1

 

other words, we could write like this:

$cart_products = $cart->get_products(true);
$last_count = count($cart_products)-1;
$last_item = $cart_products[$last_count];
Link to comment
Share on other sites

To simplify that a bit:

$cart_products = $cart->get_products( true );
$last_item = end( $cart_products );

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

@@Solomono and @@kymation for both  :beers: and thank you.

 

with this code echo $withComma = implode(",", $last_item); I get everything separated with comma.

 

Now I try get only e.g. name echo $products_array['name'] or quantity $products_array['quantity'], any idea.

Link to comment
Share on other sites

@@burt Can you give me some example.

 

and is possible show last products ONLY when I click on add to cart button, is right to pass some value to

tep_redirect(tep_href_link($goto 'value=showlastproducts', tep_get_all_get_params($parameters)));
Link to comment
Share on other sites

@@burt the problem is every time I goto shopping_cart.php page I see the last product.

@[member=kymation]
$cart_products = $cart->get_products( true );
$last_item = end( $cart_products );

I wanna see it only when I add one product to cart.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...