Posts Tagged ‘cart’

Show quantity in cart on each product_info.php page

Tuesday, July 21st, 2009

On the official osCommerce forum, Will asks;

Does anyone know how I could had on the product page (product_info.php), near the buy it now button, a line of text saying: You have XXXX units of this item currently in your cart.

I didn’t really read the question so gave the advice to use the in_cart class for this. Wrong!

Will then went away and came up with some code to do this, which is like this:

PHP:

  1. $superid = $product_info['products_id'];
  2. $products = $cart->get_products();
  3. for ($i=0, $n=sizeof($products); $i<$n; $i++) {
  4. if ($products[$i]['id'] == $superid) {
  5. $qtyencart = $products[$i]['quantity'];
  6. echo“Vous avez $qtyencart unité de cet item dans votre panier actuellement.”;
  7. break;
  8. }
  9. }

Workable, but ugly and complicated. Here’s my take on getting the same thing, coded to osCommerce conventions;

PHP:

  1. echo $cart->get_quantity($product_info['products_id']);

will bring you the number of products in the cart on the product info page. Use this with sprintf to show the text;

includes/languages/english/product_info.php

PHP:

  1. define(‘TEXT_THE_QUANTITY’, ‘You have %s units of this item currently in your cart.’);

includes/languages/french/product_info.php

PHP:

  1. define(‘TEXT_THE_QUANTITY’, ‘Vous avez %s unité de cet item dans votre panier actuellement.’);

in product_info.php

PHP:

  1. echo sprintf(TEXT_THE_QUANTITY, $cart->get_quantity($product_info['products_id']));

Pretty easy!

Go here to read the rest:
Show quantity in cart on each product_info.php page

Donate To Charity – Reloaded!

Thursday, October 9th, 2008

OK, so it was brought to my attention that my system only is available at the same time as purchasing a product. There is a good reason for this => it’s an order_total module so it needs to have an order made to process it – and standard osCommerce does not allow an order to be made without products…

So, with a bit of lateral thinking I came up with a solution – use a faux (false) product. Easy in theory and fairly easy in practice…

1. Need to recode the shopping_cart box to always show the cart subtotal. Needed to do this to show the inputted charity amount even if no products are in the cart.

2. Need to recode the shopping cart page to show the update cart, checkout, buttons at all times. Needed in order to be able to input the charity amount and begin the checkout procedure.

3. Need to recode the checkout_shipping page to add 1 extra line of code to add a false (cost zero) product if the cart has a total of exactly zero items in it, and the cart total does not = zero. In other words, a charity donation. If there is already a real product in the cart along with a donation, then this is un-needed of course.

4. Add an extra contribution to skip the checkout_shipping calculations if the cart only has the faux product and donation in it.

5. A couple of small changes in application_top.php in order to deal with the adding and removal of the charity amount, and consequently the adding and removal of the faux product.

Here is a video showing the system in action. Obviously it still needs cleaning up a lot (sponsor needed for this if anyone is interested), and is on my test shop hence the messy layout. But it should give a general idea of where the contribution is at right now.

More:
Donate To Charity – Reloaded!

How to build an eCommerce website using osCommerce Part 1

Thursday, January 24th, 2008

How to build an eCommerce website using osCommerce Part 1

A step by step video tutorial guide to building your own ecommerce website using the free open source software “oscommerce” Also available at stevebraithwaite.com

http://www.youtube.com/v/Ua9D826uTPc?f=videos&app=youtube_gdata

See original here:

How to build an eCommerce website using osCommerce Part 14

Thursday, January 17th, 2008

How to build an eCommerce website using osCommerce Part 14

295onlinestore.com

http://www.youtube.com/v/Gdy-86cFY_I?f=videos&app=youtube_gdata

Originally posted here:

How to build an eCommerce website using osCommerce Part 13

Wednesday, January 16th, 2008

How to build an eCommerce website using osCommerce Part 13

295onlinestore.com

http://www.youtube.com/v/HEZ3M4LSipU?f=videos&app=youtube_gdata

Excerpt from:

How to build an eCommerce website using osCommerce Part 12

Wednesday, January 16th, 2008

How to build an eCommerce website using osCommerce Part 12

295onlinestore.com

http://www.youtube.com/v/kZfvYuJ2pF0?f=videos&app=youtube_gdata

Read more:

How to build an eCommerce website using osCommerce Part 11

Wednesday, January 16th, 2008

How to build an eCommerce website using osCommerce Part 11

295onlinestore.com

http://www.youtube.com/v/FDdcQZpuU10?f=videos&app=youtube_gdata

Original post:

How to build an eCommerce website using osCommerce Part 10

Wednesday, January 16th, 2008

How to build an eCommerce website using osCommerce Part 10

295onlinestore.com

http://www.youtube.com/v/lhDqUgKWBDQ?f=videos&app=youtube_gdata

Originally posted here:

How to build an eCommerce website using osCommerce Part 8

Wednesday, January 16th, 2008

How to build an eCommerce website using osCommerce Part 8

295onlinestore.com

http://www.youtube.com/v/CqdXQCUkCP0?f=videos&app=youtube_gdata

See the article here:

How to build an eCommerce website using osCommerce Part 5

Wednesday, January 16th, 2008

How to build an eCommerce website using osCommerce Part 5

295onlinestore.com

http://www.youtube.com/v/g9WqUkFzEgc?f=videos&app=youtube_gdata

See the rest here: