WebsiteBaker Support (2.8.x) > Bakery Shop

Is there bestsellers snippet yet?

<< < (2/5) > >>

Bug:
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...

Bug:
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

Bug:
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: ---$database->query("UPDATE ".TABLE_PREFIX."mod_bakery_items SET stock = stock - '$quantity' WHERE item_id = '$item_id'");
--- End code ---

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: ---$database->query("UPDATE ".TABLE_PREFIX."mod_bakery_items SET bestseller = bestseller + '$quantity' WHERE item_id = '$item_id'");
--- End code ---

these lines apear several times in the view.php

enclosed a view.php from the latest bakery version


[gelöscht durch Administrator]

Bug:
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 ...

Bug:
last step:

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



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


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

[gelöscht durch Administrator]

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version