Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Disable Specific Product from Customers who bought/selected also purchased...

Disable Specific Product from Customers who bought/selected also purchased...

Locked

Views: 4,048

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
10 Feb 2008, 4:50 PM
#1
dharma avatar

dharma

Totally Zenned

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

Disable Specific Product from Customers who bought/selected also purchased...

Is there a way to disable a specific product from being listed in the> Customers who bought this item also purchased... (product info)

and the > Customers who selected the items in your cart also chose... (shopping cart)

without disabling the feature compeletly for other products?

The product I am trying to disable is a Document Product but can be checked out, all my other products are Product General.

25 Dec 2009, 1:15 AM
#2
dharma avatar

dharma

Totally Zenned

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

Re: Disable Specific Product from Customers who bought/selected also purchased...

still have this issue....what is the db table that effects Customers who bought/selected also purchased?

can I simply go in (phpmyadmin) and delete a specific product #? to edit the Customers who bought/selected also purchased selection?

I have one product that I do not wish to appear in Customers who bought also purchased sections.

25 Dec 2009, 3:57 PM
#3
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Disable Specific Product from Customers who bought/selected also purchased...

This would not show products_id 12 in the Also Purchased:

<?php
/**
 * also_purchased_products.php
 *
 * @package modules
 * @copyright Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: also_purchased_products.php 5369 2006-12-23 10:55:52Z drbyte $
 */
if (!defined('IS_ADMIN_FLAG')) {
  die('Illegal Access');
}
if (isset($_GET['products_id']) && SHOW_PRODUCT_INFO_COLUMNS_ALSO_PURCHASED_PRODUCTS > 0 && MIN_DISPLAY_ALSO_PURCHASED > 0) {

  $also_purchased_products = $db->Execute(sprintf(SQL_ALSO_PURCHASED, (int)$_GET['products_id'], (int)$_GET['products_id']));

  $num_products_ordered = $also_purchased_products->RecordCount();

  $row = 0;
  $col = 0;
  $list_box_contents = array();
  $title = '';

  $skipped = 0;
  // show only when 1 or more and equal to or greater than minimum set in admin
  if ($num_products_ordered >= MIN_DISPLAY_ALSO_PURCHASED && $num_products_ordered > 0) {
    if ($num_products_ordered < SHOW_PRODUCT_INFO_COLUMNS_ALSO_PURCHASED_PRODUCTS) {
      $col_width = floor(100/$num_products_ordered);
    } else {
      $col_width = floor(100/SHOW_PRODUCT_INFO_COLUMNS_ALSO_PURCHASED_PRODUCTS);
    }

    while (!$also_purchased_products->EOF) {
      if ($also_purchased_products->fields['products_id'] == 12) { // skip 12
        $skipped ++;
        // do nothing
      } else {
      $also_purchased_products->fields['products_name'] = zen_get_products_name($also_purchased_products->fields['products_id']);
      $list_box_contents[$row][$col] = array('params' => 'class="centerBoxContentsAlsoPurch"' . ' ' . 'style="width:' . $col_width . '%;"',
      'text' => (($also_purchased_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($also_purchased_products->fields['products_id']), 'products_id=' . $also_purchased_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $also_purchased_products->fields['products_image'], $also_purchased_products->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br />') . '<a href="' . zen_href_link(zen_get_info_page($also_purchased_products->fields['products_id']), 'products_id=' . $also_purchased_products->fields['products_id']) . '">' . $also_purchased_products->fields['products_name'] . '</a>');

      $col ++;
      if ($col > (SHOW_PRODUCT_INFO_COLUMNS_ALSO_PURCHASED_PRODUCTS - 1)) {
        $col = 0;
        $row ++;
      }
      } // skip 10
      $also_purchased_products->MoveNext();
    }
  }
  if ($also_purchased_products->RecordCount() - $skipped > 0 && ($also_purchased_products->RecordCount() - $skipped) >= MIN_DISPLAY_ALSO_PURCHASED) {
    $title = '<h2 class="centerBoxHeading">' . TEXT_ALSO_PURCHASED_PRODUCTS . '</h2>';
    $zc_show_also_purchased = true;
  }
}
?>
25 Dec 2009, 5:03 PM
#4
dharma avatar

dharma

Totally Zenned

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

Re: Disable Specific Product from Customers who bought/selected also purchased...

Hi Linda! Merry Xmas!

Thanks for your post/code! It works with a few edits, the product_12 does not appear on the product info page, but still appears in the shopping cart "Customers who selected the items in your cart also chose..."

is there a way to get rid of that also?

here's the code you gave me/I edited slightly aka > $skipped = 0; changed to > $skipped = 12;

<?php
/**
 * also_purchased_products.php
 *
 * @package modules
 * @copyright Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: also_purchased_products.php 5369 2006-12-23 10:55:52Z drbyte $
 */
if (!defined('IS_ADMIN_FLAG')) {
  die('Illegal Access');
}
if (isset($_GET['products_id']) && SHOW_PRODUCT_INFO_COLUMNS_ALSO_PURCHASED_PRODUCTS > 0 && MIN_DISPLAY_ALSO_PURCHASED > 0) {

  $also_purchased_products = $db->Execute(sprintf(SQL_ALSO_PURCHASED, (int)$_GET['products_id'], (int)$_GET['products_id']));

  $num_products_ordered = $also_purchased_products->RecordCount();

  $row = 0;
  $col = 0;
  $list_box_contents = array();
  $title = '';

  $skipped = 12;
  // show only when 1 or more and equal to or greater than minimum set in admin
  if ($num_products_ordered >= MIN_DISPLAY_ALSO_PURCHASED && $num_products_ordered > 0) {
    if ($num_products_ordered < SHOW_PRODUCT_INFO_COLUMNS_ALSO_PURCHASED_PRODUCTS) {
      $col_width = floor(100/$num_products_ordered);
    } else {
      $col_width = floor(100/SHOW_PRODUCT_INFO_COLUMNS_ALSO_PURCHASED_PRODUCTS);
    }

    while (!$also_purchased_products->EOF) {
      if ($also_purchased_products->fields['products_id'] == 12) { // skip 12
        $skipped ++;
        // do nothing
      } else {
      $also_purchased_products->fields['products_name'] = zen_get_products_name($also_purchased_products->fields['products_id']);
      $list_box_contents[$row][$col] = array('params' => 'class="centerBoxContentsAlsoPurch"' . ' ' . 'style="width:' . $col_width . '%;"',
      'text' => (($also_purchased_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($also_purchased_products->fields['products_id']), 'products_id=' . $also_purchased_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $also_purchased_products->fields['products_image'], $also_purchased_products->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br />') . '<a href="' . zen_href_link(zen_get_info_page($also_purchased_products->fields['products_id']), 'products_id=' . $also_purchased_products->fields['products_id']) . '">' . $also_purchased_products->fields['products_name'] . '</a>');

      $col ++;
      if ($col > (SHOW_PRODUCT_INFO_COLUMNS_ALSO_PURCHASED_PRODUCTS - 1)) {
        $col = 0;
        $row ++;
      }
      } // skip 12
      $also_purchased_products->MoveNext();
    }
  }
  if ($also_purchased_products->RecordCount() - $skipped > 12 && ($also_purchased_products->RecordCount() - $skipped) >= MIN_DISPLAY_ALSO_PURCHASED) {
    $title = '<h2 class="centerBoxHeading">' . TEXT_ALSO_PURCHASED_PRODUCTS . '</h2>';
    $zc_show_also_purchased = true;
  }
}
?>
25 Dec 2009, 5:29 PM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Disable Specific Product from Customers who bought/selected also purchased...

This line needs to be 0:

  $skipped = 12; 

This line needs to use 0:

 if ($also_purchased_products->RecordCount() - $skipped > 12 && ($also_purchased_products->RecordCount() - $skipped) >= MIN_DISPLAY_ALSO_PURCHASED) { 

$skipped is a counter ... not a products_id ...

The only thing you needed to change was the line:

      if ($also_purchased_products->fields['products_id'] == 12) { // skip 12

That is the products_id being tested ... everything else is to offset the counters for if this product is in the SELECT statement so things count correctly with 1 less on the counts ...

25 Dec 2009, 5:43 PM
#6
dharma avatar

dharma

Totally Zenned

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

Re: Disable Specific Product from Customers who bought/selected also purchased...

Hmmmm... didn't work the first time around, thats why I added the 12....funny it worked with my crazy edits:wacko:

I replaced the 12s with 0 as it should be.....now it works(yay), I do not see product_12 on product info page, but still seeing product_12 in shopping cart: "Customers who selected the items in your cart also chose..."

is there another edit/or file to get rid of this also?

25 Dec 2009, 6:10 PM
#7
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Disable Specific Product from Customers who bought/selected also purchased...

You might have an add on for the shopping cart ... that is not part of Zen Cart ...

25 Dec 2009, 6:18 PM
#8
dharma avatar

dharma

Totally Zenned

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

Re: Disable Specific Product from Customers who bought/selected also purchased...

whoops! using old upsell mod on cart page.....I forgot it was a mod sorry:bangin:

Thanks again for your help! :clap:

other ZC folk remember to make this an override file:lookaroun