Zen Cart Logo
Forums / General Questions / Display Cart After Adding Product based on Product Type?

Display Cart After Adding Product based on Product Type?

Locked

Views: 2,117

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
24 Jun 2008, 9:38 PM
#1
dharma avatar

dharma

Totally Zenned

Join Date:
Nov 2006
Posts:
505
Plugin Contributions:
0

Display Cart After Adding Product based on Product Type?

hello!

I currently have "Display Cart After Adding Product set to false" in my admin. It works great, but I was wondering if it was at all possible have a different product type Display the Cart After Adding Product? while leaving the default false in the admin?

or is there coding some work around for this? :lookaroun

25 Jun 2008, 4:23 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Display Cart After Adding Product based on Product Type?

/includes/init_includes/init_cart_handler.php has this:```
if (DISPLAY_CART == 'true') {
$goto = FILENAME_SHOPPING_CART;
$parameters = array('action', 'cPath', 'products_id', 'pid', 'main_page');
} else {
$goto = $_GET['main_page'];
if ($_GET['action'] == 'buy_now') {
$parameters = array('action', 'products_id');
} else {
$parameters = array('action', 'pid', 'main_page');
}
}

If you change it to the following, you can probably accomplish what you're after:```
[B]  $prod_type = 0;
  $sql = "select products_type from " . TABLE_PRODUCTS . " where products_id = '" . (int)$_GET['products_id'] . "'";
  $zp_type = $db->Execute($sql);
  if ($zp_type->RecordCount() != 0) {
    $prod_type = $zp_type->fields['products_type'];
  }[/B]
  if (DISPLAY_CART == 'true'[B] || in_array($prod_type, array(1, 2, 3))[/B]) {
    $goto =  FILENAME_SHOPPING_CART;
    $parameters = array('action', 'cPath', 'products_id', 'pid', 'main_page');
  } else {
    $goto = $_GET['main_page'];
    if ($_GET['action'] == 'buy_now') {
      $parameters = array('action', 'products_id');
    } else {
      $parameters = array('action', 'pid', 'main_page');
    }
  }
```where 1,2,3 is a comma-separated list of product-type numbers for which you want it to go to the shopping cart even though the admin setting is set at false.
26 Jun 2008, 2:02 AM
#3
dharma avatar

dharma

Totally Zenned

Join Date:
Nov 2006
Posts:
505
Plugin Contributions:
0

Re: Display Cart After Adding Product based on Product Type?

The above code doesn't seem to work...:sadwalk:

assuming the product URL is something like:

document_product_info&cPath=11_987&products_id=8934

what substitutions of your above code do I make ?

you mentioned:

 in_array($prod_type, array(1, 2, 3))) 

is their other code to change? and do I change this line to match the products_id#? or product type #, which I guess is 4?

 in_array($prod_type, array(8934)))
```?

```php
 in_array($prod_type, array(4)))
```?
26 Jun 2008, 2:23 AM
#4
dharma avatar

dharma

Totally Zenned

Join Date:
Nov 2006
Posts:
505
Plugin Contributions:
0

Re: Display Cart After Adding Product based on Product Type?

I tried both above, but to no success.

26 Jun 2008, 5:16 AM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Display Cart After Adding Product based on Product Type?

If your product was configured using the "Document-Product" type, then you would enter a "4" instead of "1,2,3", since "4" is the number of the Document-Product type according to Admin->Catalog->Product Types

I found a syntax error in my initial post.

This:if ($zp_type->RecordCount() [B]==[/B] 0) { should be this:```
if ($zp_type->RecordCount() [B]!=[/B] 0) {

26 Jun 2008, 10:31 PM
#6
dharma avatar

dharma

Totally Zenned

Join Date:
Nov 2006
Posts:
505
Plugin Contributions:
0

Re: Display Cart After Adding Product based on Product Type?

Works Perfectly! :rolleyes:

Thank you DrByte! :cheers: