Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Change Add To Cart Behavior Target


matsusaki

Recommended Posts

Posted

I've used other carts in the past - such as the WebAssist MX Cart - where you can define what page to goto next after adding an item to the cart. Very handy ifyou're trying to guide an order process - or if you have both items that need shipping or don't. For example, if I sold books and ebooks, the ebooks don't need to be shipped, so I would just have the shopper goto the payment page, not the shipping one.

 

I was wondering, is there a contrib out there that let's the admin choose the target after add?

 

Or how can I change the add to cart behavior so that it doesn't goto the cart, but to a page I can specify.

 

Hope that was clear.

 

Thanks in advance,

 

mm

Posted

You're asking a couple of different things.

 

First, osCommerce already understands the concept of "virtual" orders that don't require shipping. If the shipping weight is zero and you have enabled the "downloadable product" feature in admin, then it will skip directly to the payment page when the customer checks out.

 

Now for add to cart, do you always want it to go to the same page, or do you need to select the page depending on the product? This code in includes/application_top.php:

    if (DISPLAY_CART == 'true') {
     $goto =  FILENAME_SHOPPING_CART;
     $parameters = array('action', 'cPath', 'products_id', 'pid');
   } else {
     $goto = basename($PHP_SELF);
     if ($HTTP_GET_VARS['action'] == 'buy_now') {
       $parameters = array('action', 'pid', 'products_id');
     } else {
       $parameters = array('action', 'pid');
     }
   }

determines where the user will be taken after they do an add. The $goto variable is set to the desired target, which is either the shopping cart if that option is enabled in admin, or back to the page they were on. You can edit this as needed.

Posted

Steve -

 

You're awesome! Thanks for pointing out the code for me. I'm off to the house and tackle it tonight after the day job. The site is for a friend of mine and I'm starting to feel guilty for not getting this figured out sooner.

 

In the code sample for application_top.php, do I set:

 

$goto = basename($PHP_SELF);

 

to

 

$goto = myfile.php($PHP_SELF);

 

The example of the virtual product probably wasn't the best to use. In our case, we're trying to guide the order process. We only have one product, but have many additions to that product and want to guide that process along. Let's say it's a three step process. Do I need to have multiple 'application_top.' files?

 

Sorry for all the questions, but this one has been burning a hole in me.

 

Have a great weekend,

 

mm

 

You're asking a couple of different things.

 

First, osCommerce already understands the concept of "virtual" orders that don't require shipping.  If the shipping weight is zero and you have enabled the "downloadable product" feature in admin, then it will skip directly to the payment page when the customer checks out.

 

Now for add to cart, do you always want it to go to the same page, or do you need to select the page depending on the product?  This code in includes/application_top.php:

 ? ?if (DISPLAY_CART == 'true') {
? ? ?$goto = ?FILENAME_SHOPPING_CART;
? ? ?$parameters = array('action', 'cPath', 'products_id', 'pid');
? ?} else {
? ? ?$goto = basename($PHP_SELF);
? ? ?if ($HTTP_GET_VARS['action'] == 'buy_now') {
? ? ? ?$parameters = array('action', 'pid', 'products_id');
? ? ?} else {
? ? ? ?$parameters = array('action', 'pid');
? ? ?}
? ?}

determines where the user will be taken after they do an add.  The $goto variable is set to the desired target, which is either the shopping cart if that option is enabled in admin, or back to the page they were on.  You can edit this as needed.

Archived

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

×
×
  • Create New...