Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Adding/Modifying Fields in the Main Product Table

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #21  
Old 05-31-2012, 01:48 AM
 
sofiane sofiane is offline
 

Newbie
  
Join Date: May 2012
Posts: 1
 

Default Re: Adding/Modifying Fields in the Main Product Table

Bringing this back to life.

Okay so we have the extra field linked to the database and displaying the value for the new column, in this case "artist".

Now, how do we allow our vendors to modify those values? How do we modify those values when adding a new product? When I go inot the admin area and I want to add a new product I can't modify the value for "artist" because its not included in the form. How do we include it?

Thanks.
__________________
sf
Reply With Quote
  #22  
Old 04-16-2019, 02:34 PM
 
elmirage001 elmirage001 is offline
 

X-Wizard
  
Join Date: Apr 2007
Posts: 1,966
 

Default Re: Adding/Modifying Fields in the Main Product Table

Quote:
Originally Posted by PhilJ
OK, here's how it's done in v4.1.x ...
1) Add a new product text field called 'artist'...
Patch the database...
Code:
ALTER TABLE `xcart_products` ADD `artist` TEXT NOT NULL ;
2) include/product_modify.php
Look for...
Code:
# Update product data
Within...
Code:
$query_data = array( ... );
Along similar lines add...
Code:
"artist" => $artist,
3) skin1/main/product_details.tpl
Add this code in a suitable place...
Code:
<tr> {if $geid ne ''}<td width="15" class="TableSubHead"><input type="checkbox" value="Y" name="fields[artist]" /></td>{/if} <td class="FormButton" nowrap="nowrap">Artist</td> <td class="ProductDetails"><input type="text" name="artist" size="18" value="{if $product.productid eq ""}{else}{$product.artist}{/if}" /></td> </tr>
Or for predefined options...
Code:
<tr> {if $geid ne ''}<td width="15" class="TableSubHead"><input type="checkbox" value="Y" name="fields[artist]" /></td>{/if} <td class="FormButton" nowrap="nowrap">Artist</td> <td class="ProductDetails"> <select name="artist"> <option value=""{if $product.artist eq ""} selected{/if}>None</option> <option value="Van Gogh"{if $product.artist eq "Van Gogh"} selected{/if}>Van Gogh</option> <option value="Picasso"{if $product.artist eq "Picasso"} selected{/if}>Picasso</option> </select> </td> </tr>
That's it!
To use the field on your product page, (skin1/customer/main/product.tpl), use this code...
Code:
{$product.artist}
To use the field on your products page, (skin1/customer/main/products.tpl or products_t.tpl), use this code...
Code:
{$products[product].artist}
v4.4.x use this code
Code:
{$product.artist}
I used this to create a custom Image Alt Tag for product images instead of it defaulting to the product name.

Thank you Phil! This may be an old post but it's a GREAT one!!

Paul
__________________
X-Cart GoldPlus v4.7.12 | reBOOT (reDUX) Template v4.7.12.9 | Always The Best
Reply With Quote

The following user thanks elmirage001 for this useful post:
Zubairkhanzhk (04-01-2020)
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 11:19 AM.

   

 
X-Cart forums © 2001-2020