Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Help With Remove Buy It Now Button


Teamjr

Recommended Posts

Hello,

 

Would appreciate some help in my coding error. What I need to happen is when product is greater than zero to show buy it now button, which it does correctly. But when product is zero, I need the button to be removed and text to be displayed defined by (NON_ONLINE_ITEM), but instead of text, I get the retail price? What did I mis?

 

Thanks JR

 

Original line below in product_listing.php puts buy it now button in listing.

 

case 'PRODUCT_LIST_BUY_NOW':

$lc_align = 'center';

$lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing[$x]['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';

break;

}

 

---------------------------------------------------------------------------------

 

Replaced it with below, and should have quoted out of stock when inventory is less than zero, but it puts in the products price?

 

$lc_align = 'center';

if ( $listing[$x]['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[$x]['products_id']) .'">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';

 

}

else

{

$buy_now_button_array[] = NON_ONLINE_ITEM ;

}

 

break;

}

Link to comment
Share on other sites

Try this instead

 

case 'PRODUCT_LIST_BUY_NOW':
$lc_align = 'center';
If (($listing['products_quantity']<>0) and ($listing['products_price'] > 0)){
$lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing[$x]['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';
}else{	
$lc_text = NON_ONLINE_ITEM;
}
break;

Search the forum and contributions before posting. If that doesn't work, keep looking, then post. The forum is for seeking help and advice NOT for someone to do your work for you. Try to do something on your on, if you are going to run a shop then learn how it works.

Link to comment
Share on other sites

Nice,

 

Thank you works great. May I ask, where did I go wrong, probably from the beginning??? Hope someday I can be of some help to you.

 

Thanks JR

Link to comment
Share on other sites

$buy_now_button_array[] = NON_ONLINE_ITEM;

 

Should have been

 

$lc_text = NON_ONLINE_ITEM;

 

That's why the else statement was for before it.

Search the forum and contributions before posting. If that doesn't work, keep looking, then post. The forum is for seeking help and advice NOT for someone to do your work for you. Try to do something on your on, if you are going to run a shop then learn how it works.

Link to comment
Share on other sites

Hello Nick,

 

I jumped the gun a little and maybe you can help. I thought that would fix all, but if I do a search for an item and it shows, and I thought it used product_listing for that output for it, it defaults to the out of stock text. This is what I have in advanced_search_results.php,

 

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;

}

}

 

Thanks JR

Link to comment
Share on other sites

I am not sure what you are asking?

Search the forum and contributions before posting. If that doesn't work, keep looking, then post. The forum is for seeking help and advice NOT for someone to do your work for you. Try to do something on your on, if you are going to run a shop then learn how it works.

Link to comment
Share on other sites

Hello,

 

Again thanks for the direction. I was just posting the working code. I changed it a little to the below and it works,

 

//start no button if quantity 0

case 'PRODUCT_LIST_BUY_NOW':

$lc_align = 'center';

if ( $listing[$x]['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[$x]['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';

}else{

$lc_text = NON_ONLINE_ITEM;

}

break;

 

//end no button if quantity 0

 

Thanks jR

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...