| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | Mark Forums Read | User manuals | Login |
Adding field to product table and updating from admin | ||||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||||
|
|||||||||
Adding field to product table and updating from admin
** SOLUTION is 6 posts or so below **
I'm trying to add a checkbox field to my products table and update it through the product modify in the backend. I keep getting errors. So frustrated. I'm trying to add a field called discontinued that would be a yes/no checkbox. The problem is either in the product_modify.tpl or in the include/product_modify.php files. I could have swore that there is a post here that covers this but after searching for 2 hours, I give up. HELP ME PLEASE. here is where I added to my product_modify.php Code:
and here is my .tpl Code:
|
|||||||||
#2
|
|||||||||
|
|||||||||
What did you set that field as in MySQL? (data type, length...)
|
|||||||||
#3
|
|||||||||
|
|||||||||
CHAR, 1, Not null, Default = N
I basically copied the field attributes from apply_pst/apply_gst. |
|||||||||
#4
|
|||||||||
|
|||||||||
I think you want it to be like this:
Code:
See how I moved the discontinued= infront of the where. See if this helps. Carrie
__________________
Custom Development, Custom Coding and Pre-built modules for X-cart since 2002! We support X-cart versions 3.x through 5.x! Home of the famous Authorize.net DPM & CIM Modules, Reward Points Module, Point of Sale module, Speed Booster modules and more! Over 200 X-cart Mods available & Thousands of Customizations Since 2002 - bcsengineering.com Please E-Mail us for questions/support! |
|||||||||
#5
|
|||||||||
|
|||||||||
I'm gonna fix that now, thanks so much Carrie. I feel like for not catching that. That was probably the problem.
My advice to anyone. If you are frustrated, walk away. Sometimes, you will not be able to see the answer in front of you. |
|||||||||
#6
|
|||||||||
|
|||||||||
No problem. I find the same thing. I get so burnt out and wraped up in code sometimes, it's just a simple semicolon or missordering of something that gets resolved by just walking away and taking a break!
Post the errors you're getting if that doesn't completely fix it. And maybe we can figure it out. Carrie
__________________
Custom Development, Custom Coding and Pre-built modules for X-cart since 2002! We support X-cart versions 3.x through 5.x! Home of the famous Authorize.net DPM & CIM Modules, Reward Points Module, Point of Sale module, Speed Booster modules and more! Over 200 X-cart Mods available & Thousands of Customizations Since 2002 - bcsengineering.com Please E-Mail us for questions/support! |
|||||||||
#7
|
|||||||||
|
|||||||||
Well my code above was a complete mess but I got it working now.
To add a checkbox field to the xcart_products table and have it updateable in the admin here we go (3.5.7) Edit skin1/main/product_modify.tpl and add Code:
where you want it to appear, I added it after the </tr> for discount avail. You will need to create a language label tag (in my example I am using discontinued) to identify what the checkbox is for {$lng.lbl_discontinued}. Be sure to add a field to the end of your xcart_products database table. The attributes should be Quote:
Lastly you need to modify include/product_modify.php Change this area Code:
to Code:
You'll notice that everywhere in the above I am using discontinued. This is the name of the field I wanted to add and should make it easy for you to find all of my changes. Thanks to BCSE and Telafirma for lending their ears. Can we get this added to Custom mods? I spent two hour looking for this information before starting this thread. Keywords: insert checkbox, insert field, add field, product modify |
|||||||||
#8
|
|||||||||
|
|||||||||
I should also add that you can now use this checkbox field in the skin1/customer/main/product.tpl such as
{if $product.discontinued eq "N"}DO THIS{/if} Very handy for being able to turn on and off specific features in individual products. |
|||||||||
#9
|
|||||||
|
|||||||
Hi, I'm on v4.0.15.
I am just wondering would this code still work? would it interfere with the standard extra field on xcart? Just needed to make sure since this post is from 2years ago.
__________________
X-Cart Gold 4.0.17 |
|||||||
#10
|
|||||||
|
|||||||
Hi,
I created fields in my SQL, and that went well. Then, I edited include/product_modify.php , that went ok, too. Then I edited my skin1/main/product_details.tpl (here you listed product_modify.tpl but I guess v4. that changed to product_details.tpl) well.. so far everything looks good, but when I went in to admin, all those field I added doesn't update to the database. Is there anyother places I need to modify the code in order to get the value updated to the database? any tips would be great, thank you.
__________________
X-Cart Gold 4.0.17 |
|||||||
|
Thread Tools | Search this Thread |
|
|
|
|||
X-Cart forums © 2001-2020
|