Jump to content

Changing 'On Sale' items in sidebar


GeorgeBlackman
 Share

Recommended Posts

Hello everyone.

 

I've been tasked with changing the items in the On Sale sidebar. Is there any way to specify which items are displayed? It's been displaying the same 5 products since the site was set up and I see nowhere in the admin screen that will allow me to change them.

 

I was hoping there is piece of code somewhere that I could directly edit but after searching I can't find anything.

 

I'm running v5.2.

 

Any guidence would be greatly appreciated. Thanks!

Link to comment
Share on other sites

If you do a view source on your website you will see the code that makes the products visible. You could then copy this, edit it to show the products you want and then replace the relevent code that displays the on sale items in the main.php file. So basically instead of auto generating the list it is coded in similar to this.

In main.php replace {$SALE_ITEMS} with something like this:


<div id="sale_products">
<h3>On Sale</h3>
<ul>
    <li>
     <a href="https://demo.cubecart.com/cc5/tv-home-cinema/3d-tvs/sony-kdl-32hx753-3d-tv.html"title="Sony KDL-32HX753 3D TV">Sony KDL-32HX753 3D TV</a><br />
     <span class="saving">Save &pound;41.01</span>    </li>
    <li>
     <a href="https://demo.cubecart.com/cc5/3d-glasses-tdg-br200/w.html"title="3D Glasses TDG-BR200/W">3D Glasses TDG-BR200/W</a><br />
     <span class="saving">Save &pound;4.24</span>    </li>
</ul>
</div>

Add as many items as required.

This has it's drawbacks as you have to keep checking to make sure products are in stock or if you change prices etc. There is probably a more elegant solution that uses a query to randomise the products shown so that is maybe what you are looking for but if you want to show specific items then this should work.

Link to comment
Share on other sites

Brilliant, thanks a lot. The drawbacks aren't too much of an issue as I'll be changing them manually anyway as they don't want them randomised.

 

I do have another question though. I have found this snippet in the source code when right clicking it on Firefox, but I'm not sure of where to edit the source to make changes to the site. Do you mean use this code in the main.php file in place of {$SALE_ITEMS}? Or is there a file where I can directly edit the source code?

 

Sorry I'm new to this CubeCart business. Thanks again!

Link to comment
Share on other sites

You could make changes to the box.sale_items.php file but replacing the {$SALE_ITEMS} in the main.php file is basically the same thing. Then if you want to return to the way it was you just need to remove the code you put in and replace it with the {$SALE_ITEMS} again.

Link to comment
Share on other sites

If you do a view source on your website you will see the code that makes the products visible. You could then copy this, edit it to show the products you want and then replace the relevent code that displays the on sale items in the main.php file.

This has it's drawbacks as you have to keep checking to make sure products are in stock or if you change prices etc. There is probably a more elegant solution that uses a query to randomise the products shown so that is maybe what you are looking for but if you want to show specific items then this should work.

 

As a new user, be aware that editing code within core files would mean that you would have to make the changes each and every time you do an upgrade.  It may seem like a small change but it is a slippery slope that many users are still falling into and which V5 / V6 coding structure was supposed to prevent.  It would be much better to have a plugin developed to have more control over what sale products are displayed.  

 

Ian

Link to comment
Share on other sites

Great, thank you very much. I'll give it a go and hopefully it doesn't crash their website and ruin the business.


Yeah I understand this. The site is not new but I am new to it. There are already a few mods which have been made which is why I havn't upgraded yet; I'm not confident I'll be able to complete the whole process, replace the current mods while keeping everything up and running. For now I'll bodge it with some code edits and worry about it later. I appreciate your sentiments though, so thanks.

Link to comment
Share on other sites

I've decided to change the box.sale_items.php file as I like to keep my changes as seperate from the existing code as possible.

 

I do have one more question. This method doesnt show the product images. Do you happen to know the code piece I would need to include to get them to display?

 

Once again, thank you very much.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...