WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Bakery Shop => Topic started by: zirzy on July 18, 2011, 07:59:44 PM

Title: Is there bestsellers snippet yet?
Post by: zirzy on July 18, 2011, 07:59:44 PM
Hi!
Yes, i wanna know how can i show best selling items to customers? Is this kind of snippet out yet? Or is it easy to build from older snippets?
Title: Re: Is there bestsellers snippet yet?
Post by: zirzy on October 15, 2011, 12:07:25 PM
Ok, i think i can use last_items module with little changes to a mysql to show best selling products in frontpage of the store.. If somebody can just give me help for changing mysql code?

I have done some changes but it doesn´t give me accurate answers.. ( It´s been 5 years since last mysql coding  :-P)
Title: Re: Is there bestsellers snippet yet?
Post by: Bug on November 01, 2011, 08:08:00 PM
I guess the item table needs an extra field where you can keep track of the amount of items that are sold

With that variable you can select the bestsellers

I guess in the view_summary you should add the new amount to the existing amount

I see nice possibilities, I will take this up soon
Title: Re: Is there bestsellers snippet yet?
Post by: zirzy on November 02, 2011, 09:09:42 AM
Hi Bug,

Thanks for your help! I´m looking forward to this ;)
Title: Re: Is there bestsellers snippet yet?
Post by: dbs on November 02, 2011, 09:15:12 AM
Quote
I´m looking forward to this
me too  :wink:
Title: Re: Is there bestsellers snippet yet?
Post by: Bug on November 02, 2011, 07:32:35 PM
I am off to work right now, will try the new baker (I presume to functions are still just as lame as they where last update),

I will first make a snippet for my 'slighty' altered backery-with-another-name and when it works I will post it...

Can't be too hard...
Title: Re: Is there bestsellers snippet yet?
Post by: Bug on November 02, 2011, 09:19:23 PM
first step:

add a field to the bakery_item table

I called it bestseller

name: bestseller
set it to: int

do not set it to varchar because that will occur in not sorting the right way
Title: Re: Is there bestsellers snippet yet?
Post by: Bug on November 02, 2011, 09:25:33 PM
2nd step:

add some stuff in view.php

what is already there?
whenever an amount of items is bought, the stock amount of those items are decreased by some lines like

Code: [Select]
$database->query("UPDATE ".TABLE_PREFIX."mod_bakery_items SET stock = stock - '$quantity' WHERE item_id = '$item_id'");
what do we want?
we want that at the same time as the stock is updated to update the field 'bestseller' and decrease the amount for that field with the amount of bought items ..

so we add
Code: [Select]
$database->query("UPDATE ".TABLE_PREFIX."mod_bakery_items SET bestseller = bestseller + '$quantity' WHERE item_id = '$item_id'");
these lines apear several times in the view.php

enclosed a view.php from the latest bakery version


[gelöscht durch Administrator]
Title: Re: Is there bestsellers snippet yet?
Post by: Bug on November 02, 2011, 09:27:26 PM
now with these minor changes we keep track of how many times an item is bought ...

as we test it, and buy 40 sjits where the stock was 50 sjits, we see 10 sjits remaining in stock and 40 sjits in bestsellerfield ...

Title: Re: Is there bestsellers snippet yet?
Post by: Bug on November 02, 2011, 09:54:48 PM
last step:

install the last_items and change the way it orders the items ...


Code: [Select]
$query_items = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_bakery_items WHERE active = '1' AND title != '' ORDER BY bestseller DESC LIMIT ".$num_items);

you can even show the amount of items that are sold:

[gelöscht durch Administrator]
Title: Re: Is there bestsellers snippet yet?
Post by: zirzy on November 03, 2011, 08:53:01 AM
How nice is that! :) Thank you Bug! I have to test this as soon as possible (now i have to work).

Thanks again!! ;)
Title: Re: Is there bestsellers snippet yet?
Post by: Bug on November 03, 2011, 05:42:49 PM
you know how to style the last_items?...

as this is made from last items you can style is the same way, in the enclosed file above I already made a possibillity to show the amount of sold items ...


if freesbee reads this... if you can put in the bestsellers-field into the next release + the minor alterations to the view.php the snippet could be a standard usable snippet ...


Title: Re: Is there bestsellers snippet yet?
Post by: Bug on November 04, 2011, 05:37:11 PM
@ zirzy:
Freesbee responded positive and with any luck the bestsellersfunction and snippet can be a standard thing in the near future ...
Title: Re: Is there bestsellers snippet yet?
Post by: zirzy on November 05, 2011, 03:17:58 PM
Yes I know ;) Thank you very much Bug. That would be great idea to add it in the new version of Bakery. I will look forward to this new Bakery :)
Title: Re: Is there bestsellers snippet yet?
Post by: zirzy on November 05, 2011, 05:29:40 PM
One question:
If I wanna use last items and bestsellers together. Do i have to change from include.php (rows 29 and 30) function_exists(last_items) to for example function_exists(bestsellers) and call it on my template index.php with the same name?
Title: Re: Is there bestsellers snippet yet?
Post by: Bug on November 06, 2011, 01:17:59 PM
Change everytime lastitems occurs into bestsellers, do NOT forget the info file

So when you install them, both last items and bestsellers get installed

Last items is a rather smal set of files so it is easy to do by hand, with larger amounts of files I usually use dreamweavers find and replace (case sensitive) to replace all instances of the modulenam and directory...

Search for last_items and LAST_ITEMS


With acts like these you can for instance even change 'bakery' into something called 'shop'
Title: Re: Is there bestsellers snippet yet?
Post by: zirzy on November 06, 2011, 07:27:25 PM
Here is last items modifyed to bestsellers (see attachment). Is it ok?
I tested bestseller snippet together with last items and it worked fine.

[gelöscht durch Administrator]
Title: Re: Is there bestsellers snippet yet?
Post by: Bug on November 07, 2011, 07:17:28 PM
Next thing:

Other buyers also bought...

Idea: in the view_item  (detail page) randomly display two or three items that have been bought by people that bought that specific item...

Can be made from any_items

Might be possible without altering bakery...

Code can be easily insterted into view detailed info with showsection droplet

Show section droplet needs to have extra lines like

If (empty($content)){
$content=' ';
}else{
$content = $content;
}
To prevent having errors if there are no items to display....
Title: Re: Is there bestsellers snippet yet?
Post by: zirzy on November 08, 2011, 08:46:14 AM
That would be cool idea for Bakery! So this snippet gives customer more hints what other customers have bought with this specific product. So choice is already made for customer ;) NICE!

I have to test this in the future :)
Title: Re: Is there bestsellers snippet yet?
Post by: Bug on November 08, 2011, 01:48:29 PM
working on that one ...

needs quite some creative thinking ... and puzzling ...
Title: Re: Is there bestsellers snippet yet?
Post by: dbs on November 08, 2011, 02:37:01 PM
i could also need this "Other buyers also bought...".

At the moment i dublicate some items into a extra bakery-section and call this section with a modified last-items-script and let order by position.
Title: Re: Is there bestsellers snippet yet?
Post by: seanie_morris on February 02, 2017, 08:19:23 PM
Was there any movement on this snippet? It would be a nice little addition...

Seanie.