Hiding "Add to Cart" on global cross-sell

Questions and answers about ShopSite Custom Templates

Hiding "Add to Cart" on global cross-sell

Postby nsd999 » Fri Sep 30, 2011 12:12 am

Hi,

I'm listing Bestselling Products on our homepage via global cross-sell but would like to remove the "Add to Cart" buttons. Can this be done?

Thanks,
Joe
nsd999
 
Posts: 17
Joined: Thu May 05, 2011 12:05 pm

Re: Hiding "Add to Cart" on global cross-sell

Postby Jim » Fri Sep 30, 2011 8:52 am

Edit the Global cross sell section of the Shopping cart template and remove the code that displays the add to cart button.

Since the same code is used on both the Shopping cart and pages for global cross sell products you might want to modify the code to display it slightly different in the two different places. For pages you could create a VAR to indicate that you are on a page and then execute the code based on the VAR value. Something like
At the top of the page template add.
[-- VAR.onpage "true" --]

at the bottom of the page template add
[-- VAR.onpage "false" --]

Then in the global cross sell section add

[-- if VAR.onpage "true" --]
put the code for the global cross sell without the add to cart buttons here
[-- Else --]
put the code for the global cross-sell with the add to cart buttons here.
[-- end_if --]

So if you are on a page the VAR.onpage will force the first section of code to be executed since the value is "true". And on the shopping cart the VAR.onpage is either false or not defined so the section of code will be executed. Note that you could add a [-- VAR.onpage "false" --] at the top of the shopping cart template (not in the define for the global cross sell but in the define shopping cart section ) just to make sure that the VAR is defined and set to false so the second section of code would be executed.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Re: Hiding "Add to Cart" on global cross-sell

Postby nsd999 » Fri Sep 30, 2011 10:44 am

Hi Jim,

Thanks for the reply.

I'm a little confused though because I don't see the cart template referenced from the custom page template.

Actually let's backtrack a little please. What is the recommended way for modifying a built-in template? Currently if I found that I need to change code I copy the shop site template file to new name, make my changes, and update the reference to the new name. In thinking about this though if the modified file is referenced anywhere else my changes won't be placed in effect due to the new name, correct? This doesn't seem like the best approach. And what happens when the built-in theme is officially updated? Are some of the files that my site is using changed to new versions which may possibly cause things to break?

So I guess in essence, how do I correctly modify a template file if I'm not sure where/when it is referenced?

Thanks,
Joe
nsd999
 
Posts: 17
Joined: Thu May 05, 2011 12:05 pm

Re: Hiding "Add to Cart" on global cross-sell

Postby Jim » Fri Sep 30, 2011 12:35 pm

The cart template is in its own section under Commerce Setup > Order System >Layout. To find out what template is being used you would go to the screen where that is set; Pages > Edit Page Layout; Products > Edit Product Layout; Commerce Setup > Order System > Layout Info ; etc.

Then go to Merchandising > Custom Templates > and select the template type button for the type of template you are trying to modify. Click the Copy ShopSite template button. Select the ShopSite template and fill in the file name field and click copy. That will take you back to the screen where you select the template and edit it. So edit it and make your changes and save them. Then Select the template you just edited and click the Copy Template and this time give it the same name as the ShopSite template that you originally copied. Now when the template is called during publish or in the shopping cart etc. it will use the one that you modified instead of the ShopSite provided template. Your changes will also not be lost on an upgrade this way because the ShopSite templates are replace during the upgrade process.

Note that you may need to modify an include file instead of the main template. So you would need to look at the main template and find the code you want to modify and if it is in an include file you will need to modify that file using the same method described above.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Re: Hiding "Add to Cart" on global cross-sell

Postby nsd999 » Fri Sep 30, 2011 12:52 pm

Hi Jim,

Thanks for the info. Although it is a bit cumbersome - I wonder if the developers could have made it a little more straight-forward to customize a theme without the renames..

I'll assume that once I copy it back to the original name I can just select it again & click edit without renaming, etc..

BUT.

If I only modify some of the files in a template can a Shopsite upgrade change the other template files I haven't touched and possibly wreck havoc with my design?
nsd999
 
Posts: 17
Joined: Thu May 05, 2011 12:05 pm

Re: Hiding "Add to Cart" on global cross-sell

Postby Jim » Fri Sep 30, 2011 3:10 pm

It was originally configured so you could copy a ShopSite template and give it the same name. We had lots of complaints that their store no longer worked and they couldn't get back to the ShopSite template because it was being overridden by the copy. So it was decided that the best solution was to force the user to know what they were doing when they wanted to modify a template, thus the copy to a new name, then copy again to get the ShopSite template name if that is what they wanted.

Yes, once it has been renamed back to the ShopSite name you can just click and edit it. But remember that that is the file now being used, so make sure you don't leave it in a buggy state or your store may not function correctly.

You are correct, if you just modify some of the template files and a new release modifies something that uses the part you modified, it could cause problems in the store. If you are making a number of changes it would be better to create your own template and include files, etc so an upgrade isn't going to affect them.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah


Return to Custom Template Questions

Who is online

Users browsing this forum: No registered users and 88 guests

cron