| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Free Gifts Module | ||||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
Free Gifts Module
I originally made this module for a Version 3.4.14 installation. It basically allows the store admin to define "Free Gifts" that are offered to the customer if they spend a certain amount. The Free Gifts should have a price of 0.00, be available for sale, and be in a category that can't be accessed via normal browsing of the site.
I also recently got it to work on a Version 4.0.12 installation and added a feature called Notification Price that tells the customer that if they spend $XX more they'll get a free gift. I'll post those differences and modifications in another post. STEP 1 -------- Add a "Free Gifts" menu item (or whatever you want to call it) to the admin menu under "Inventory". We put it just under "Coupons". In /skin1/provider/menu.tpl, add: Code:
STEP 2 -------- Create the Free Gifts table in the database. We called it "xcart_freegifts" and it has the following structure: Code:
STEP 3 -------- Create a bunch of functions in func.php for handling the Free Gifts. Some of the function might be reduntant but I just made what I needed and didn't think too much about it. Code:
STEP 4 -------- Create provider/freegifts.php for handling all the admin modifications to the Free Gifts. Here's the code for that page: Code:
STEP 5 -------- Add the redirect call in skin1/single/home.tpl just below Coupons for consistency. Code:
STEP 6 -------- Create skin1/provider/main/freegifts.tpl. The code is as follows: Code:
STEP 7 -------- Add the promotion text somewhere at the bottom of skin1/customer/main/cart_totals.tpl. The code below is just a generic version. Modify it to fit your site design. Code:
STEP 8 -------- Add the following code to customer/cart.php. Somewhere at the top, maybe after "$intershipper_recalc = 'Y'", put: Code:
After the code that checks if the cart is empty and includes the Discount Coupons module if it's active, below "$smarty->assign('cart', $cart);", and above the Redirect code put the code below. Keep in mind that it's very important that this code be put in the right place otherwise your additions and removals from your cart won't work properly. Code:
Lastly, send the two arrays to the smarty templating engine: Code:
STEP 9 -------- In skin1/customer/main/product.tpl you'll have to change the code that prints the price of the item. Our product.tpl is heavily modified so all I can say is that instead of showing a text input field when the price is 0.00 you should put text that says "FREE!" or something like that. For us, it looks something like this: Code:
STEP 10 ---------- In skin1/customer/main/cart.tpl or skin1/customer/main/cart_contents.tpl (depending on your setup) you have to do something along these lines so that the quantity input field doesn't show up if it's a free gift: Code:
Atul |
|||||||
#2
|
|||||||
|
|||||||
Changes for version 4.0.12
Here is the code for a Version 4.0.12 installation and the feature called Notification Price that tells the customer that if they spend $XX more they'll get a free gift. You'll need to refer to the previous posting to make sense of some of the steps.
STEP 1 -------- This step should be as follows: Code:
STEP 2 -------- The "xcart_freegifts" table now has the following structure: Code:
STEP 3 -------- The following functions were either modified or added: Code:
STEP 4 -------- provider/freegifts.php is also different: Code:
STEP 5 -------- No changes to this step... STEP 6 -------- skin1/provider/main/freegifts.tpl is also different: Code:
STEP 7 -------- skin1/customer/main/cart_totals.tpl is also different: Code:
STEP 8 -------- Instead of modifying customer/cart.php, you have to modify cart.php in the root directory of your store. The top section which gets the active free gifts stays the same, but the other sections are modified as follows: Code:
Code:
STEP 9 -------- I also noticed you have to modify skin1/customer/main/product.tpl so that the customer cannot select more than 1 free item at a time. So in addition to the other changes, do something like the following in the section where it prints the quantity select box: Code:
STEP 10 --------- No changes to this step... Atul |
|||||||
#3
|
|||||||||
|
|||||||||
great adition. do you have this live somewhere for a look ?
__________________
Looking for a reliable X-cart host ? You wont go wrong with either of these. EWD Hosting Hands On Hosting |
|||||||||
#4
|
|||||||
|
|||||||
__________________
Padraic Ryan Ryan Design Studio Professional E-Commerce Development |
|||||||
#5
|
|||||||||
|
|||||||||
love it, works a treat
__________________
Looking for a reliable X-cart host ? You wont go wrong with either of these. EWD Hosting Hands On Hosting |
|||||||||
#6
|
|||||||
|
|||||||
Hi balinor
Nice site and the mod works well, just noticed this Code:
__________________
X-Cart V4.0.18 PHP 4.3.10 MySQL Server 4.0.22 Apache/1.3.33 (unix) OS - Linux |
|||||||
#7
|
|||||||
|
|||||||
Just have to make sure that if you are using the html catalog, you don't generate a nice static version of the hidden product for the SE's to spider
And yea, like I said, still testing
__________________
Padraic Ryan Ryan Design Studio Professional E-Commerce Development |
|||||||
#8
|
|||||||
|
|||||||
Free Gifts
Can you tell me if this would work in that module.
Buy this item and get this item for $x.xx Can the user choose the free gift i.e. if there is more than one? Cheers
__________________
GerryB Xcart 4.0.11 ____________ Remember not to forget that which you do not need to know. |
|||||||
#9
|
|||||||
|
|||||||
Quote:
Is this a bug in my code? Atul |
|||||||
#10
|
|||||||
|
|||||||
No, the product had 'free' in the title Changed that and it was fine.
__________________
Padraic Ryan Ryan Design Studio Professional E-Commerce Development |
|||||||
|
|||
X-Cart forums © 2001-2020
|