Zen Cart Logo
Forums / General Questions / Products won t switch on or off

Products won t switch on or off

Views: 1,557

Results 1 to 8 of 8
12 Apr 2013, 7:09 AM
#1
nicksab avatar

nicksab

Totally Zenned

Join Date:
Apr 2011
Posts:
592
Plugin Contributions:
0

Products won t switch on or off

Hey everyone,

Something strange is happening to my site https://www.royal-fleur.com

I can switch any categories on or off ( red / green button ) but I cannot turn any of the products on or off.

This problem is for all the products in each one of the categories.

Does anyone know what could be the problem?

Thank you in advance for your help

12 Apr 2013, 7:59 AM
#2
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Products won t switch on or off

It's generally a master categories ID conflict.

Try this:

  1. backup your database

  2. Go to TOOLS >>> STORE MANAGER >>> Reset ALL Products Master Categories ID (Click RESET)

13 Apr 2013, 6:26 AM
#3
nicksab avatar

nicksab

Totally Zenned

Join Date:
Apr 2011
Posts:
592
Plugin Contributions:
0

Re: Products won t switch on or off

schoolboy:

It's generally a master categories ID conflict.

Try this:

  1. backup your database

  2. Go to TOOLS >>> STORE MANAGER >>> Reset ALL Products Master Categories ID (Click RESET)

I tried what you suggested but it did not change anything.

I can switch any category on or off but I cannot switch on or off any product inside any of the category.

I know i can switch the product on or off thru sql but the red/green button option is much easier

13 Apr 2013, 7:08 AM
#4
nicksab avatar

nicksab

Totally Zenned

Join Date:
Apr 2011
Posts:
592
Plugin Contributions:
0

Re: Products won t switch on or off

I just noticed today that if I had upload a new product into any of the category, the product status is set to off ( red square ) automatically.

The newly added product won t turn on ( green ) whatsoever and it does not matter how many time i click on that small square. The page will just refresh and the square stays red. I have to go to the sql and change the product_status to 1

What could be causing this? it is only affecting product and not categories status??

The product do turn on if i switch the whole category or subcategory off then back on. All product are on this way. I just cannot switch them individually

13 Apr 2013, 7:30 AM
#5
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: Products won t switch on or off

do oyu have Image Handler installed, and zen Cart 1.5.x? Image handler contains code for ZC 1.3.x, and breaks 1.5

if so, open YOUR_ADMIN/includes/modules/category_product_listing.php in a tekst editor.
find 1.3.x code (arround line 159)```php

<?php if ($categories->fields['categories_status'] == '1') { echo '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'action=setflag_categories&flag=0&cID=' . $categories->fields['categories_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image(DIR_WS_IMAGES . 'icon_green_on.gif', IMAGE_ICON_STATUS_ON) . '</a>'; } else { echo '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'action=setflag_categories&flag=1&cID=' . $categories->fields['categories_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image(DIR_WS_IMAGES . 'icon_red_on.gif', IMAGE_ICON_STATUS_OFF) . '</a>'; } if (zen_get_products_to_categories($categories->fields['categories_id'], true, 'products_active') == 'true') { echo '  ' . zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', IMAGE_ICON_LINKED); } ?>
and replace with original 1.5 code```php
<?php
      if ($categories->fields['categories_status'] == '1') {
        echo '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'action=setflag_categories&flag=0&cID=' . $categories->fields['categories_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ((isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : '')) . '">' . zen_image(DIR_WS_IMAGES . 'icon_green_on.gif', IMAGE_ICON_STATUS_ON) . '</a>';
      } else {
        echo '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'action=setflag_categories&flag=1&cID=' . $categories->fields['categories_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ((isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : '')) . '">' . zen_image(DIR_WS_IMAGES . 'icon_red_on.gif', IMAGE_ICON_STATUS_OFF) . '</a>';
      }
      if (zen_get_products_to_categories($categories->fields['categories_id'], true, 'products_active') == 'true') {
        echo '  ' . zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', IMAGE_ICON_LINKED);
      }
?>

next find 1.3.x code (around line 336) ```php

<?php if ($products->fields['products_status'] == '1') { echo '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'action=setflag&flag=0&pID=' . $products->fields['products_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image(DIR_WS_IMAGES . 'icon_green_on.gif', IMAGE_ICON_STATUS_ON) . '</a>'; } else { echo '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'action=setflag&flag=1&pID=' . $products->fields['products_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image(DIR_WS_IMAGES . 'icon_red_on.gif', IMAGE_ICON_STATUS_OFF) . '</a>'; } if (zen_get_product_is_linked($products->fields['products_id']) == 'true') { echo '  ' . zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', IMAGE_ICON_LINKED) . '<br>'; } ?>
and replace with original 1.5 code
```php
<?php
      if ($products->fields['products_status'] == '1') {
        echo zen_draw_form('setflag_products', FILENAME_CATEGORIES, 'action=setflag&pID=' . $products->fields['products_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ((isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : ''));?>
        <input type="image" src="<?php echo DIR_WS_IMAGES ?>icon_green_on.gif" title="<?php echo IMAGE_ICON_STATUS_ON; ?>" />
        <input type="hidden" name="flag" value="0" />
        </form>
<?php
      } else {
        echo zen_draw_form('setflag_products', FILENAME_CATEGORIES, 'action=setflag&pID=' . $products->fields['products_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ((isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : ''));?>
        <input type="image" src="<?php echo DIR_WS_IMAGES ?>icon_red_on.gif" title="<?php echo IMAGE_ICON_STATUS_OFF; ?>"/>
        <input type="hidden" name="flag" value="1" />
        </form>
<?php
      }
      if (zen_get_product_is_linked($products->fields['products_id']) == 'true') {
        echo '  ' . zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', IMAGE_ICON_LINKED) . '<br>';
      }
?>

that is what worked for me

14 Apr 2013, 3:20 AM
#6
nicksab avatar

nicksab

Totally Zenned

Join Date:
Apr 2011
Posts:
592
Plugin Contributions:
0

Re: Products won t switch on or off

I do have IH 4 installed, hideCategories on ZC 1.5.1

I realized that both modified the file you mentioned. I did the changed you suggested and it fixed the problem

Thank you very much for your help

17 Apr 2013, 10:59 PM
#7
tandmrider211 avatar

tandmrider211

New Zenner

Join Date:
Jan 2012
Posts:
7
Plugin Contributions:
0

Re: Products won t switch on or off

I did find a work around. The product status is automatically set to "out of stock". As soon as I click "in stock" the product is enabled. Same as my products that I want to disable. I just need to check "out of stock" for the product status and it's disabled. That's easier for a dope like me that finds code a bit over my head.

Cheers.

17 Apr 2013, 11:13 PM
#8
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: Products won t switch on or off

> Design75:

do oyu have Image Handler installed, and zen Cart 1.5.x? Image handler contains code for ZC 1.3.x, and breaks 1.5

if so, open YOUR_ADMIN/includes/modules/category_product_listing.php in a tekst editor.
find 1.3.x code (arround line 159)```php

<?php if ($categories->fields['categories_status'] == '1') { echo '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'action=setflag_categories&flag=0&cID=' . $categories->fields['categories_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image(DIR_WS_IMAGES . 'icon_green_on.gif', IMAGE_ICON_STATUS_ON) . '</a>'; } else { echo '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'action=setflag_categories&flag=1&cID=' . $categories->fields['categories_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image(DIR_WS_IMAGES . 'icon_red_on.gif', IMAGE_ICON_STATUS_OFF) . '</a>'; } if (zen_get_products_to_categories($categories->fields['categories_id'], true, 'products_active') == 'true') { echo '  ' . zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', IMAGE_ICON_LINKED); } ?>
> and replace with original 1.5 code```php
<?php
      if ($categories->fields['categories_status'] == '1') {
        echo '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'action=setflag_categories&flag=0&cID=' . $categories->fields['categories_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ((isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : '')) . '">' . zen_image(DIR_WS_IMAGES . 'icon_green_on.gif', IMAGE_ICON_STATUS_ON) . '</a>';
      } else {
        echo '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'action=setflag_categories&flag=1&cID=' . $categories->fields['categories_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ((isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : '')) . '">' . zen_image(DIR_WS_IMAGES . 'icon_red_on.gif', IMAGE_ICON_STATUS_OFF) . '</a>';
      }
      if (zen_get_products_to_categories($categories->fields['categories_id'], true, 'products_active') == 'true') {
        echo '  ' . zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', IMAGE_ICON_LINKED);
      }
?>

next find 1.3.x code (around line 336) ```php

<?php if ($products->fields['products_status'] == '1') { echo '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'action=setflag&flag=0&pID=' . $products->fields['products_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image(DIR_WS_IMAGES . 'icon_green_on.gif', IMAGE_ICON_STATUS_ON) . '</a>'; } else { echo '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'action=setflag&flag=1&pID=' . $products->fields['products_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image(DIR_WS_IMAGES . 'icon_red_on.gif', IMAGE_ICON_STATUS_OFF) . '</a>'; } if (zen_get_product_is_linked($products->fields['products_id']) == 'true') { echo '  ' . zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', IMAGE_ICON_LINKED) . '<br>'; } ?>
> and replace with original 1.5 code
> ```php
<?php
      if ($products->fields['products_status'] == '1') {
        echo zen_draw_form('setflag_products', FILENAME_CATEGORIES, 'action=setflag&pID=' . $products->fields['products_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ((isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : ''));?>
        <input type="image" src="<?php echo DIR_WS_IMAGES ?>icon_green_on.gif" title="<?php echo IMAGE_ICON_STATUS_ON; ?>" />
        <input type="hidden" name="flag" value="0" />
        </form>
<?php
      } else {
        echo zen_draw_form('setflag_products', FILENAME_CATEGORIES, 'action=setflag&pID=' . $products->fields['products_id'] . '&cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ((isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : ''));?>
        <input type="image" src="<?php echo DIR_WS_IMAGES ?>icon_red_on.gif" title="<?php echo IMAGE_ICON_STATUS_OFF; ?>"/>
        <input type="hidden" name="flag" value="1" />
        </form>
<?php
      }
      if (zen_get_product_is_linked($products->fields['products_id']) == 'true') {
        echo '  ' . zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', IMAGE_ICON_LINKED) . '<br>';
      }
?>

that is what worked for me

> nicksab:

I do have IH 4 installed, hideCategories on ZC 1.5.1

I realized that both modified the file you mentioned. I did the changed you suggested and it fixed the problem

Thank you very much for your help
Sure.. you can do all of this..

**OR..

**you could have simply installed the latest version of Image Handler (updated Feb, 2013) which FIXES this problem..

No code editing required..