Remove Add To Cart Button, add Call To Order

There was another post about wanting to remove the add to cart button and replacing it with text that says something like “Please Call To Place Your Order”



I provided a fix, but it wasn’t really that great. So I thought about it and came up with a better fix.



There have also been some posts in the past about having the cart as just a catalog and not actually using it as a store. This mod should take care of that as well, kind of.



I have attached the mod to this post and as long as you haven’t modified any of the same files you should just be able to overwrite you files with these. Make sure you put the files in the right skin folder.



A demo can be seen at:



[url]http://www.jandkonline.com/cscart[/url]



The product that is set is the book The Zen of CSS Design : Visual Enlightenment for the Web (Voices That Matter)



Here are some screen shots:



Admin:







Index:







Categories:







Details:







The instructions are below.



1.)In you phpmyadmin add:


ALTER TABLE `cscart_products` ADD `call` CHAR( 1 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N' AFTER `product_code`





2.) Add new language variable:


Language variable: call_order
Value: Please Call To Place Your Order




3.) In core/fn.catalog.php



After:


// Define fields that should be retrieved
$fields = array (
'products.product_id',
'descr1.product as product',
'products.tracking',
'products.feature_comparison',
'products.zero_price_action',
'products.product_type',
'products.tax_ids',
'products.weight',




Add:


'products.call',







4.) In schemas/exim/products.php



After:


'Quantity' => array (
'#db_field' => 'amount'
),




Add:


'Call' => array (
'#db_field' => 'call'
),






And After:


'S' => array ( // selectboxes
'status' => array (
'name' => 'products_data',
'variants' => array (
'A' => 'active',
'D' => 'disabled',
'H' => 'hidden'
),
),




Add:


'call' => array (
'name' => 'products_data',
'variants' => array (
'Y' => 'yes',
'N' => 'no',
),
),






5.) In skins/your-skin/admin/views/products/update.tpl



After:

```php


{$lang.price} ({$currencies.$primary_currency.symbol}) :

class="input-text-medium" />
```

Add:
```php

{$lang.call_order}:

{$lang.no}
{$lang.yes}


```

6.) Create a file called: skins/your-skin/customer/addons/my_changes/hooks/products/buttons_block.override.tpl

In that file put:
```php
{if $product.call == "Y"}

{$lang.call_order}


{else}
{if !($product.zero_price_action == "R" && $product.price == 0) && !($settings.General.inventory_tracking == "Y" &&

$settings.General.allow_negative_amount != "Y" && ($product.amount <= 0 || $product.amount < $product.min_qty) &&

$product.is_edp != "Y" && $product.tracking == "B")}
<{if $separate_buttons}div class="buttons-container"{else}span{/if} id="cart_add_block_{$obj_id}">
{if $product.avail_since <= $smarty.const.TIME || ($product.avail_since > $smarty.const.TIME &&

$product.buy_in_advance == "Y")}
{if $product.has_options && !$show_product_options && !$details_page}
{include file="buttons/button.tpl" but_id="button_cart_`$obj_id`"

but_text=$lang.select_options but_href="$index_script?dispatch=products.view&product_id=`$product.product_id`"

but_role="text" but_name=""}
{else}
{if $extra_button}{$extra_button} {/if}
{include file="buttons/add_to_cart.tpl" but_id="button_cart_`$obj_id`"

but_name="dispatch[checkout.add..`$obj_id`]" but_role=$but_role}
{assign var="cart_button_exists" value=true}
{/if}
{/if}
{if $product.avail_since > $smarty.const.TIME}
{include file="common_templates/coming_soon_notice.tpl" avail_date=$product.avail_since

add_to_cart=$product.buy_in_advance}
{/if}

{elseif ($product.amount <= 0 || $product.amount < $product.min_qty) && $product.tracking == "B"}

{$lang.text_out_of_stock}


{/if}

{if $show_list_buttons}
<{if $separate_buttons}div class="buttons-container"{else}span{/if} id="cart_buttons_block_{$obj_id}">
{hook name="products:buy_now"}
{if $product.feature_comparison == "Y"}
{if $separate_buttons}
{/if}
{include file="buttons/add_to_compare_list.tpl" product_id=$product.product_id}
{/if}
{/hook}

{/if}
{/if} ```


What is added is just:

```php {if $product.call == "Y"}

{$lang.call_order}


{else} ```

And of course the closing {/if}

This is where you would select the class and such to change the look.

That's it, your done.

Brandon

call_order.zip

Thanks brandon this is great, I will try it as I do need this for some products that I have and not able to sell online . Also I would love to find a way to do something like this for products availability, if the product is in stock I want to show a text saying will ship in 24 hours and for not in stock products to show will ship in 5 days or something like that, do you think this is possible?



Thank you

Joe

Joe,



Are you looking at some type of backorder function? What I mean is, if the item isn’t in stock do you still want the customer to be able to add it to their cart.



Or do you just want to make some text that says what you want?



If you just want text you can see:



Not in stock:



[url]http://www.jandkonline.com/cscart/hp-ipaq-hx2415-pocket-pc.html[/url]



In Stock:



[url]http://www.jandkonline.com/cscart/hp-ipaq-rz1715-pocket-pc.html[/url]



If you just want text than you can either change the language variable or the code. The problem with the language variables is that it changes everything.



The code is:



1.) Create 2 language variables:



Variable: 24_hours
Value: Will Ship Within 24 Hours


Variable: 5_days
Value: Will Ship Within 5 Days




2.) Create a file called skins/your-skin/customer/addons/my_changes/hooks/products/options_advanced.override.tpl



In that file put:


```php {* $Id: options_advanced.tpl 7497 2009-08-23 17:27:21 Brandon $ *}







{if $product.is_edp !== “Y” && $settings.General.inventory_tracking == “Y” && $product.tracking != “D”}

{if !$simple}




{if ($product.amount <= 0 || $product.amount < $product.min_qty) && $product.tracking == "B"}
{$lang.5_days }

{/if}


{else}


{if ($product.amount <= 0 || $product.amount < $product.min_qty) && $product.tracking == "B"}
{$lang.5_days}
{/if}

{/if}
{/if}

{if $show_qty}
{if ($product.qty_content || $show_qty) && $product.is_edp !== "Y" && $cart_button_exists == true && ($settings.General.allow_anonymous_shopping == "Y" || $auth.user_id)}

{$lang.quantity}:
{if $product.qty_content}

{foreach from=$product.qty_content item="var"}
{$var}
{/foreach}

{else}

{/if}

{if $product.prices}
{include file="views/products/components/products_qty_discounts.tpl"}
{/if}
{elseif !$bulk_add}

{/if}
{/if} ```

3.) Create a file called skins/your-skin/customer/addons/my_changes/hooks/products/buttons_block.override.tpl

In this file put:

```php {if $product.call == "Y"}
{if !($product.zero_price_action == "R" && $product.price == 0) && !($settings.General.inventory_tracking == "Y" && $settings.General.allow_negative_amount != "Y" && ($product.amount <= 0 || $product.amount < $product.min_qty) && $product.is_edp != "Y" && $product.tracking == "B")}
<{if $separate_buttons}div class="buttons-container"{else}span{/if} id="cart_add_block_{$obj_id}">
{if $product.avail_since <= $smarty.const.TIME || ($product.avail_since > $smarty.const.TIME && $product.buy_in_advance == "Y")}
{if $product.has_options && !$show_product_options && !$details_page}
{include file="buttons/button.tpl" but_id="button_cart_`$obj_id`" but_text=$lang.select_options but_href="$index_script?dispatch=products.view&product_id=`$product.product_id`" but_role="text" but_name=""}
{else}
{if $extra_button}{$extra_button} {/if}
{include file="buttons/add_to_cart.tpl" but_id="button_cart_`$obj_id`" but_name="dispatch[checkout.add..`$obj_id`]" but_role=$but_role}
{assign var="cart_button_exists" value=true}
{/if}
{/if}
{if $product.avail_since > $smarty.const.TIME}
{include file="common_templates/coming_soon_notice.tpl" avail_date=$product.avail_since add_to_cart=$product.buy_in_advance}
{/if}


{/if}

{if $show_list_buttons}
<{if $separate_buttons}div class="buttons-container"{else}span{/if} id="cart_buttons_block_{$obj_id}">
{hook name="products:buy_now"}
{if $product.feature_comparison == "Y"}
{if $separate_buttons}
{/if}
{include file="buttons/add_to_compare_list.tpl" product_id=$product.product_id}
{/if}
{/hook}

{/if} ```

4.) In skins/you-skin/customer/common_templates/product_data.tpl

Change:

```php {if ($product.amount >= 0 && $product.amount > $product.min_qty) || $product.tracking != "B"}

{$lang.in_stock}


{/if} ```

To:

```php {if ($product.amount >= 0 && $product.amount > $product.min_qty) || $product.tracking != "B"}

{$lang.24_hours}


{/if} ```


If you want to still allow the products to be added to the cart than you'll need to change your settings to allow for negative inventory.

I hope this is what you were looking for.

Brandon

Thank you Brandon,



What I’m trying to do is to be able to track inventory at the same time be able to sell out of stock items. I stock over 3000 products some of which are in stock and some are drop ship and special order items. So I want to let the customer know when to expect delivery of the items ordered by placing text in place of In Stock or out of stock . I think your mod will do that I will try it and let you know. How does the backorder function work?



Thank you

Joe

Absolutely Fantastic Mod. Keep it up mate :slight_smile:

Brandon,



How could I use both of the above mods together. In other words if the product have a “Call to place order” then I don’t want to show the stock option. I have been trying to get this to work but no success.



Your help is much appreciated.



Thank you



Joe

I have tried to install this modification but to no avail and I had run the query in pmpmyadmin and now the modification is always in the DB. Is there a way to remove that query from the DB as I can now not export any of my products as it throws up an error message.



Thank for help



ALTER TABLE cscart_products ADD call CHAR( 1 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ‘N’ AFTER product_code

In CS-cart v2.1.x this doen’t work.



The following cannot be found:

‘S’ => array ( // selectboxes

‘status’ => array (

‘name’ => ‘products_data’,

‘variants’ => array (

‘A’ => ‘active’,

‘D’ => ‘disabled’,

‘H’ => ‘hidden’

),

),



Anyways, if it works this is a rather usefull add-on.With some modifications you can also use it to remove the add to cart button and replace this with a “more info” button…



So please help on this topic.

BrandonVD does not have a requirement to update the addon provided. Accordingly he may not reply to this thread.

Jesse Lee,



I know that he doen’t have a requirement, but the statement in also not shown in the file I downloaded from this thread.



Maybe I understand you wrong, but what kind of attitude is that. I simply and kindly asked for help on this topic. I am actually surprised about your comment. I am on many forums and almost everybody is willing to help.



I am working on a flooring shopping cart where the square meters of the product needs to be calculated. The add to cart button is useless on the subcategory page. It needs to be a “more information” button.



So if someone wants to help, please feel free. I need all the help I can get.



Thanks to the person who wants to help in advance.



Eduard

Eduard, I’m just making sure that you don’t wait around expecting a reply anytime soon. We have a lot of ‘newbies’ sitting around and waiting on the experience forum posters for new/free updates. I understand you require help, hence the reason I posted.



I save my attitude for other occasions :slight_smile:

Eduard,



I’ll take a look at this tomorrow and see what I can do. I haven’t looked at it in a while and to be honest, I didn’t even see Joe’s and Amit’s posts. Somehow I must have just missed them.



Right now it’s about midnight here and I’m not going to go digging into this now.



Brandon

Hi Brandon sorry to bug you but did you ever happen to take a look at this?



Regards

Ok guys, finally got a chance to look at this and got it figured out.



It would be nice to make this an addon, but I’m really not sure how because of the files involved. Unfortunately this isn’t just a look and feel thing and there is a lot more involved.



Anyways, here is the solution for CS-Cart 2.1.3



1.)In you phpmyadmin add:


ALTER TABLE `cscart_products` ADD `call` CHAR( 1 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N' AFTER `product_code`





2.) Add new language variable:


Language variable: call_order
Value: Please Call To Place Your Order




3.) In core/fn.catalog.php


// Define fields that should be retrieved
$fields = array (
'products.product_id',
'products.company_id',
'companies.company as company_name',
'descr1.product as product',
'products.tracking',
'products.feature_comparison',
'products.zero_price_action',
'products.product_type',
'products.tax_ids',
'products.weight',




Add:


'products.call',







4.) In schemas/exim/products.php



After:


'Quantity' => array (
'db_field' => 'amount'
),




Add:


'Call' => array (
'#db_field' => 'call'
),




5.) In controllers/admin/products.php



After:


'S' => array ( // selectboxes
'status' => array (
'name' => 'products_data',
'variants' => array (
'A' => 'active',
'D' => 'disabled',
'H' => 'hidden'
),
),




Add:


'call' => array (
'name' => 'products_data',
'variants' => array (
'Y' => 'yes',
'N' => 'no',
),
),




6.) In skins/your-skin/admin/views/products/update.tpl



After:


```php



{$lang.price} ({$currencies.$primary_currency.symbol}) :


```

Add:

```php

{$lang.call_order}:

{$lang.no}
{$lang.yes}

```

6.) Create a file called: skins/your-skin/customer/addons/my_changes/hooks/products/buttons_block.override.tpl

In that file put:

```php {if $product.call == "Y"}

{$lang.call_order}


{else}
{if !($product.zero_price_action == "R" && $product.price == 0) && !($settings.General.inventory_tracking == "Y" && $settings.General.allow_negative_amount != "Y" && (($product_amount <= 0 || $product_amount < $product.min_qty) && $product.tracking != "D") && $product.is_edp != "Y") || ($product.has_options && !$show_product_options)}
<{if $separate_buttons}div class="buttons-container"{else}span{/if} id="cart_add_block_{$obj_prefix}{$obj_id}">
{if $product.avail_since <= $smarty.const.TIME || ($product.avail_since > $smarty.const.TIME && $product.buy_in_advance == "Y")}
{hook name="products:add_to_cart"}
{if $product.has_options && !$show_product_options && !$details_page}
{include file="buttons/button.tpl" but_id="button_cart_`$obj_prefix``$obj_id`" but_text=$lang.select_options but_href="products.view?product_id=`$product.product_id`" but_role="text" but_name=""}
{else}
{if $extra_button}{$extra_button} {/if}
{include file="buttons/add_to_cart.tpl" but_id="button_cart_`$obj_prefix``$obj_id`" but_name="dispatch[checkout.add..`$obj_id`]" but_role=$but_role block_width=$block_width obj_id=$obj_id product=$product}
{assign var="cart_button_exists" value=true}
{/if}
{/hook}
{/if}
{if $product.avail_since > $smarty.const.TIME}
{include file="common_templates/coming_soon_notice.tpl" avail_date=$product.avail_since add_to_cart=$product.buy_in_advance}
{/if}

{elseif !$details_page && ($settings.General.inventory_tracking == "Y" && $settings.General.allow_negative_amount != "Y" && (($product_amount <= 0 || $product_amount < $product.min_qty) && $product.tracking != "D") && $product.is_edp != "Y")}
{$lang.text_out_of_stock}
{/if}

{if $show_list_buttons}
<{if $separate_buttons}div class="buttons-container"{else}span{/if} id="cart_buttons_block_{$obj_prefix}{$obj_id}">
{hook name="products:buy_now"}
{if $product.feature_comparison == "Y"}
{if $separate_buttons}
{/if}
{include file="buttons/add_to_compare_list.tpl" product_id=$product.product_id}
{/if}
{/hook}

{/if}
{/if} ```

And that should do it.

Hope that helps,

Brandon

OK so you know what we’re all going to ask next, are you able to get this working for version 2.1.4? The above doesn’t seem to work.



From what I can see my fn.catalog.php looks slightly different, not sure if thats the problem.

Hmmm… It seems to work now.



I took the hash out from…



‘Call’ => array (

#db_field’ => ‘call’

),



And this seemed to fix it but I can’t be entirely sure as I messed around with loads of other bits too…

In 2.1, the hash was removed from the descriptors in the schema files.

Quickly scanning, this could be made into an addon without any modification to any standard (distributed) files.



Since Brandon has been a good customer and one of the more helpful folks here, I will work with him to help him develop this into an addon. While there may be some ‘gotcha’ somewhere, I don’t see anything above that would prevent this from being done purely with php, schema and template hooks.



Brandon, give me a shout and we’ll get this bundled up so it’s easier for the novice merchants.

That would be awesome if you could, I was very concerned when editing core files that I’m going to have to be careful when upgrading.

That would be very good, and something i would DEFINATELY pay for. Thanks