Jump to content
ce7

if special price is 0 show Quote button

Recommended Posts

Posted (edited)

Hi,

on the new CE1.0.5.0, im trying to make the quote button to show up if the SPECIAL PRICE is 0,

the origianl addon code is

//+Email For Quote v1.2
    if (is_email_for_quote($product_info['products_price'])) {
      $products_price = show_email_for_quote($product_info);
    } else if ($new_price = tep_get_products_special_price($product_info['products_id'])) {
//-Email For Quote v1.2

and to BUY button part

//BOF Email For Quote v1.2
if (!is_email_for_quote($product_info['products_price'])) {
  echo tep_draw_button(MODULE_CONTENT_PI_BUY_BUTTON_TEXT, 'fas fa-shopping-cart', null, 'primary', array('params' => 'data-has-attributes="' . (($products_attributes['total'] > 0) ? '1' : '0') . '" data-in-stock="' . (int)$product_info['products_quantity'] . '" data-product-id="' . (int)$product_info['products_id'] . '"'), 'btn-success btn-block btn-lg btn-product-info btn-buy');
  echo tep_draw_hidden_field('products_id', (int)$product_info['products_id']);
}
//EOF Email For Quote v1.2

this is what i tried but it shows Add to the cart and Quote button at the same time for all the products, how do i change it to make only special product price is 0 or product price is 0 then show Quote button, otherwise show Add to cart button?

// CE Version but show both Quote & Buy buttons
//+Email For Quote v1.2
    if (is_email_for_quote($product_info['products_price']) || $product_info['specials_new_products_price'] ==0) {
      $products_price = show_email_for_quote($product_info);
    } else if ($new_price = tep_get_products_special_price($product_info['products_id'])) {
//-Email For Quote v1.2

Many thanks!  Lyn

image.png.2719a2175995e282b272c8dc3e974593.png

image.png.e5254dc003339173bf4b121ef17abc89.png

 

Edited by ce7

Share this post


Link to post
Share on other sites

Why do you think that

$product_info['specials_new_products_price']

would contain the special's price?  The else clause shows how to get the special's price.  Perhaps

    $new_price = tep_get_products_special_price($product_info['products_id']);
    if (is_email_for_quote($product_info['products_price']) || !new_price) {
      $products_price = show_email_for_quote($product_info);
    } else {

would do what you want. 


Always back up before making changes.

Share this post


Link to post
Share on other sites

hi

thank you for reply.

i managed to make only if special price 0 then show quote button

   if (is_email_for_quote($product_info['products_price'])) {
      $products_price = show_email_for_quote($product_info);
    } elseif ($new_price = tep_get_products_special_price($product_info['products_id'])) {
    if($new_price==0 && is_email_for_quote($product_info['specials_new_products_price'])){
      $specials_price =show_email_for_quote($product_info['specials_new_products_price']);
    } 


however I can not disable the Add to Cart button

this code can make quote button when product price is 0 ---> is_email_for_quote($product_info['products_price'])

if(!is_email_for_quote($product_info['products_price'])){
  echo tep_draw_button(MODULE_CONTENT_PI_BUY_BUTTON_TEXT, 'fas fa-shopping-cart', null, 'primary', array('params' => 'data-has-attributes="' . (($products_attributes['total'] > 0) ? '1' : '0') . '" data-in-stock="' . (int)$product_info['products_quantity'] . '" data-product-id="' . (int)$product_info['products_id'] . '"'), 'btn-success btn-block btn-lg btn-product-info btn-buy');
  echo tep_draw_hidden_field('products_id', (int)$product_info['products_id']);
}


how can i make Add to Cart disappear for both product price is 0 and special product price is 0?

Many thanks!  Lyn

Share this post


Link to post
Share on other sites
    $add_to_cart = false;
    if (is_email_for_quote($product_info['products_price'])) {
      $products_price = show_email_for_quote($product_info);
    } elseif (($new_price = tep_get_products_special_price($product_info['products_id'])) && is_email_for_quote($product_info['specials_new_products_price'])) {
      $specials_price =show_email_for_quote($product_info['specials_new_products_price']);
    } else {
      $add_to_cart = tep_draw_button(MODULE_CONTENT_PI_BUY_BUTTON_TEXT, 'fas fa-shopping-cart', null, 'primary', array('params' => 'data-has-attributes="' . (($products_attributes['total'] > 0) ? '1' : '0') . '" data-in-stock="' . (int)$product_info['products_quantity'] . '" data-product-id="' . (int)$product_info['products_id'] . '"'), 'btn-success btn-block btn-lg btn-product-info btn-buy')
                  . tep_draw_hidden_field('products_id', (int)$product_info['products_id']);
    }

And then later, replace the add to cart code with

    if ($add_to_cart) {
      echo $add_to_cart;
    }

 


Always back up before making changes.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×