scrivo Posted April 23, 2010 Share Posted April 23, 2010 Hi Im installing a addon to oscommerce (In store only), which involves editing the product_listing.php file. This is the original array block of code that i need to edit: $info_box_contents[$my_row][$my_col] = array('align' => 'center', 'params' => ' style="width:25%;"', 'text' => ''.tep_draw_prod_top77().' <table cellpadding="0" cellspacing="0" border="0"> <tr> <td style="height:122px " class="pic">'.tep_draw_prod_top().''.$p_pic.''.tep_draw_prod_bottom().'</td> </tr> <tr> <td style="height:25px" class="vam" >'.$p_name.'</td> </tr> <tr> <td style="height:140px" >'.$p_desc.'<br></td> </tr> <tr> <td style="height:49px">'.$p_price.'</td> </tr> <tr> <td style="height:46px "> <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' .tep_image_button("button_details.gif").'</a><br> <br style="line-height:3px"> <a href="'.tep_href_link("products_new.php","action=buy_now&products_id=".$p_id).'">'.tep_image_button('button_add_to_cart2.gif').'</a><br> </td> </tr> </table> '.tep_draw_prod_bottom77().''); Basically, i need to exchange the line: <a href="'.tep_href_link("products_new.php","action=buy_now&products_id=".$p_id).'">'.tep_image_button('button_add_to_cart2.gif').'</a><br> For this IF statement: /* NEM Modified to check for In-store Only */ $product_status_query = tep_db_query("select in_store_only from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_new['products_id'] . "'"); $product_instore = tep_db_fetch_array($product_status_query); if ($product_instore['in_store_only'] == '0') { //original content 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_cart2.gif', IMAGE_BUTTON_IN_CART) . '</a>'; }else{ echo '<span class="markProductOutOfStock">' . TEXT_STORE_ONLY . '</span>'; } /* End Modification */ Whats the best way to go about doing this, because a simple copy and paste over the top wont work. Link to comment Share on other sites More sharing options...
MrPhil Posted April 23, 2010 Share Posted April 23, 2010 You can't, at least not without major restructuring. In the original code, you are creating a array with three elements. The "text" element is one long, long string. The easiest way to do this would probably be to move all this code up before the first line of the array, and create a temporary text variable. Down deep in the creation of "text", you use this temporary text variable. /* NEM Modified to check for In-store Only */ $product_status_query = tep_db_query("select in_store_only from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_new['products_id'] . "'"); $product_instore = tep_db_fetch_array($product_status_query); if ($product_instore['in_store_only'] == '0') { //original content $temp_text = '<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_cart2.gif', IMAGE_BUTTON_IN_CART) . '</a>'; }else{ $temp_text = '<span class="markProductOutOfStock">' . TEXT_STORE_ONLY . '</span>'; } /* End Modification */ $info_box_contents[$my_row][$my_col] = array('align' => 'center', 'params' => ' style="width:25%;"', 'text' => ''.tep_draw_prod_top77().' ... (skip much) ... <br style="line-height:3px"> ' . $temp_text . '<br> </td> </tr> ... (skip more) ... Something like that. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.