Showing Accessories for Product(s)
What it is & how it works:
Live demo: http://headsetinnovations.com/cart/product.php?productid=16266&cat=250&page=1 Screenshot: Description: What it does is include the products listing for a defined category (Accessories) and lists them under a defined product. Product & Accessories associations are stored in the x-cart MySQL database for fast processing. Installation: 1. Create a table in your x-cart database called 'sub_accessories' by running the following MySQL Query: Code:
CREATE TABLE `sub_accessories` ( 2. Create a directory under /cart/skin1 called 'subaccess' in that folder create a file called 'subaccessphp.tpl' and put the following code in subaccessphp.tpl: (Make sure you put in your MySQL databse & login information AND CHANGE 'change-to-your-store.com' to your website URL below...) Code:
{php} 2a. Then create a file under the same dir (cart/skin1/subaccess) called 'subaccessdiag.tpl' and put the following code: (This is the template that controls how the accessories are listed) Code:
{capture name=dialogacc}{section name=product loop=$products}{assign var="discount" value=0} 2b. Create a file under /cart/skin1 called 'product_thumbnail_secure.tpl' and put the following code: Code:
{if $config.Appearance.show_thumbnails eq "Y"}[img]{if $tmbn_url}{$tmbn_url|replace:[/img]{/if} 3. Create a file under /cart called 'subaccess.php' and put the following code: Code:
<?php 4. Then go to cart/skin1/customer/main/product.tpl and at the very bottom add this code: Code:
5. Now its time to associate products with their accessories. each field under the sub_accessories MySQL table has a purpose: active: 0=Disabled, 1=Enabled (Use this to turn accessory listing on or off) productid: (Set this to the productid of the product you want it to list under. You can get the productid by looking at the url where it says 'product.php?productid=16266' 16266 would be the product id you would enter. cat: (Set this to the category where your accessories are. So if you accessories are under Accessories > Product go there and look at the url and get the cat #. E.G. 'home.php?cat=628' 628 would be the cat id you would enter for your accessories. Example MySQL field setup: active: 1 productid: 16266 cat: 628 This would list accessories for productid 16266 by including products in cat 628. You can create multiple records for as many as you want! Well, I thought I would share this with everyone just in case some one had a use for this. Im not php expert im still learning PHP. Im sure there are some better ways to do some of this but this is how I have it and it works GREAT! Any suggestions/comments are welcome. Thanks, Austin Changelog: [10/30/05] - Removed MySQL login/pass & db info and added the following in subaccessphp.tpl: Code:
global $sql_host, $sql_user, $sql_db, $sql_password; Code:
global $printable; I have edited the the code above to reflect this change. |
Just wanted to say this looks like a great mod! Good work.
Don't know that I have a use for it - but it's good to see somebody else actively mod'ing on their own instead of digging for free answers 8) |
nice mod
Love the mod! I'm new at this and would love to use it I just need to know where I put the:
Example MySQL field setup: active: 1 productid: 16266 cat: 628 do I put it in product.tpl or in the subaccess.php? sorry like I said I just got this program and not a programer |
That is something you want to put in your MySQL table... You can do it by running this MySQL query:
Code:
INSERT INTO `sub_accessories` SET `active`=1, `productid`=12345, `cat`=123; Change 12345 to the productid that you will be displaying accessories under. Then change 123 to the cat # of this category you will be listing under that product. |
bit useful for selling vehicle spare parts.
|
HI anoack,
Great Mod thank you very much :D |
anyone actually apply this and have luck with it? Just curious before trying it out :)
|
I have made some small changes to the code as I have advanced in my php skills.
Changelog: [10/30/05] - Removed MySQL login/pass & db info and added the following: Code:
global $sql_host, $sql_user, $sql_db, $sql_password; |
Quote:
If you have any proplems with installation post it here or just PM me. Note: It is currently working with the version of X-Cart I have in my signature. |
THANK YOU! I have a designer with lots of add ons to her products and this would really increase sales for her.
|
All times are GMT -8. The time now is 08:32 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.