rustyclockwork Posted July 7, 2013 Posted July 7, 2013 Hello all, I did the cpidk's contribution which I'll show the instructions below. I basically wanted to have to have some extra information pages on my site, and an easy way to add them. This contrib worked great yesterday (testing) and today when I was ready to start populating with real information, the weirdest thing happened. When I added the product image to the standard product listing in admin, the contrib will not work (add to cart button appears even though 0 quantity and 0 price are inserted) The contrib will work if I do not add the product image, but it won't if I do. Below are the instructions for the contribution, and I sure do appreciate any ideas. Jason PS - I also did the "hide price if 0 and replace with a message" mod, but that was only a few lines and I don't think that did anything... =============================================================== a way to remove the "add to cart" button from productinfo if quantity is 0 file to edit (product_info.php) Installation Notes: In product_info.php <((>--Find line 213 in a clean install--<))> <?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?> <((>--Replace with--<))> //start no button if quantity 0 <?php if ( $product_info['products_quantity'] > 0 ) { echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); } else { } ?> //end no button if quantity 0 ------------------------------------------------------------------------------- Addendum : There is another file to modify : catalog/includes/modules/product_listing.php <((>--Find line 133 in a clean install--<))> $lc_text = '<a href="'.tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> '; <((>--Replace with--<))> //start no button if quantity 0 if ( $listing['products_quantity'] > 0 ) { $lc_text = '<a href="'.tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> '; } else { $lc_text = ' ' ; } //end no button if quantity 0 I hope thats all. :P ------------------------------------------------------------------------------- Re-Addendum : It wasn't all!!!! I forgot this 'little' update of index.php : <((>--Find line 133 in a clean install--<))> for ($i=0, $n=sizeof($column_list); $i<$n; $i++) { switch ($column_list[$i]) { case 'PRODUCT_LIST_MODEL': $select_column_list .= 'p.products_model, '; break; case 'PRODUCT_LIST_NAME': $select_column_list .= 'pd.products_name, '; break; case 'PRODUCT_LIST_MANUFACTURER': $select_column_list .= 'm.manufacturers_name, '; break; case 'PRODUCT_LIST_QUANTITY': $select_column_list .= 'p.products_quantity, '; break; case 'PRODUCT_LIST_IMAGE': $select_column_list .= 'p.products_image, '; break; case 'PRODUCT_LIST_WEIGHT': $select_column_list .= 'p.products_weight, '; break; } } <((>--Replace with--<))> for ($i=0, $n=sizeof($column_list); $i<$n; $i++) { switch ($column_list[$i]) { case 'PRODUCT_LIST_MODEL': $select_column_list .= 'p.products_quantity, p.products_model, '; break; case 'PRODUCT_LIST_NAME': $select_column_list .= 'p.products_quantity, pd.products_name, '; break; case 'PRODUCT_LIST_MANUFACTURER': $select_column_list .= 'p.products_quantity, m.manufacturers_name, '; break; case 'PRODUCT_LIST_QUANTITY': $select_column_list .= 'p.products_quantity, '; break; case 'PRODUCT_LIST_IMAGE': $select_column_list .= 'p.products_quantity, p.products_image, '; break; case 'PRODUCT_LIST_WEIGHT': $select_column_list .= 'p.products_quantity, p.products_weight, '; break; } } Now, that's all ------------------------------------------------------------------------------- Re-Addendum : It wasn't all!!!! I forgot this 'little' update of advanced_search_result.php : <((>--Find line 187 in a clean install--<))> for ($i=0, $n=sizeof($column_list); $i<$n; $i++) { switch ($column_list[$i]) { case 'PRODUCT_LIST_MODEL': $select_column_list .= 'p.products_model, '; break; case 'PRODUCT_LIST_MANUFACTURER': $select_column_list .= 'm.manufacturers_name, '; break; case 'PRODUCT_LIST_QUANTITY': $select_column_list .= 'p.products_quantity, '; break; case 'PRODUCT_LIST_IMAGE': $select_column_list .= 'p.products_image, '; break; case 'PRODUCT_LIST_WEIGHT': $select_column_list .= 'p.products_weight, '; break; } } <((>--Replace with--<))> for ($i=0, $n=sizeof($column_list); $i<$n; $i++) { switch ($column_list[$i]) { case 'PRODUCT_LIST_MODEL': $select_column_list .= 'p.products_quantity, p.products_model, '; break; case 'PRODUCT_LIST_MANUFACTURER': $select_column_list .= 'p.products_quantity, m.manufacturers_name, '; break; case 'PRODUCT_LIST_QUANTITY': $select_column_list .= 'p.products_quantity, '; break; case 'PRODUCT_LIST_IMAGE': $select_column_list .= 'p.products_quantity, p.products_image, '; break; case 'PRODUCT_LIST_WEIGHT': $select_column_list .= 'p.products_quantity, p.products_weight, '; break; } } ___________________________________________________________________________________ Dont forget to change products_new.php !!!!! Correction to this section by www.MediaMedley.com 1. find (about line 55): $products_new_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC, pd.products_name"; and replace with: $products_new_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_quantity, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC, pd.products_name"; 2. find (about line 89): <td align="right" valign="middle" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_NEW, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $products_new['products_id']) . '">' . tep_image_button('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</a>'; ?></td> and replace with: <td align="right" valign="middle" class="main"> <?php //start no button if quantity 0 if ( $products_new['products_quantity'] > 0 ) { echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_NEW, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $products_new['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a>'; } else { echo 'Out Of Stock' ; } //end no button if quantity 0 ?></td> I think that is that!!?? _________________________________________________________________________________________
rustyclockwork Posted July 8, 2013 Author Posted July 8, 2013 Nevermind, had some double code in one of the product pages... got it fixed now, thank you!
Recommended Posts
Archived
This topic is now archived and is closed to further replies.