If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / Display Cart After Adding Product based on Product Type?

Display Cart After Adding Product based on Product Type?

Locked

Started by dharma on 24 Jun 2008, 9:38 PM · 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

Zencart 1.3.9h - PHP 5.2.13 - My SQL 5.0.84 - Apache 1.3.41

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

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
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.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

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)))
```?

Zencart 1.3.9h - PHP 5.2.13 - My SQL 5.0.84 - Apache 1.3.41

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.

Zencart 1.3.9h - PHP 5.2.13 - My SQL 5.0.84 - Apache 1.3.41

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

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
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) {

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

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:

Zencart 1.3.9h - PHP 5.2.13 - My SQL 5.0.84 - Apache 1.3.41