Page 1 of 15 12311 ... LastLast
Results 1 to 10 of 150
  1. #1
    Join Date
    Aug 2004
    Location
    United Kingdom
    Posts
    32
    Plugin Contributions
    0

    Default Adding New Product_types

    Hi,

    I am trying to customise my Zen Cart install to create a couple of new product_types in the same way that you have added the product_music type. I am having trouble with it to be honest.

    I managed to copy the code for adding new Record Companies and rejig it to allow me to add Product Materials to a new table in my database, with a few hours of messing about, creating new language files and adding to existing files its all finished and working.

    Now I copied the file product_music.php to /admin/product_body_jewellery.php and in an attempt to create a new product type entry page where I could customise it further to allow me to have a product type that has product material and product body part options. Unfortunately, at this stage I am unsure what to do...when I try to access my new file some of the page content including header, etc is displayed but after a little while I redirected in what appears to be a redirecting loop.

    Can you tell me what the coding requirements are for setting up a new product type so that I can tinker and try and get a grasp of how this works. I think it is best that I try to implement the product_type that I require in the ZenCart and submit it to yourselves for possible inclusion of new releases rather than bombard you with requests to implement it.

    Any help would be greatly appreciated :).

  2. #2
    Join Date
    Jan 2004
    Posts
    64,748
    Blog Entries
    6
    Plugin Contributions
    74

    Default

    Good strategy!

    Did you duplicate these files as well?
    - /admin/products_music.php
    - /admin/includes/modules/product_music/*.php

    and
    - /includes/modules/pages/product_music/*.php
    - /includes/templates/TEMPLATE/templates/product_music*.php
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Aug 2004
    Location
    United Kingdom
    Posts
    32
    Plugin Contributions
    0

    Default

    Thanks for getting back to me. From what I can see I have actually duplicated all of the files for product_music to my new product type product_body_jewellery.

    [root@boar www.giftsforgoths.com]# find -name "*product_music*"
    ./admin/product_music.php
    ./admin/includes/languages/english/product_music.php
    ./admin/includes/languages/english/extra_definitions/product_music.php
    ./admin/includes/boxes/extra_boxes/product_music_extras_dhtml.php
    ./admin/includes/modules/product_music
    ./admin/includes/functions/extra_functions/product_music_functions.php
    ./includes/languages/english/product_music_info.php
    ./includes/languages/english/extra_definitions/product_music.php
    ./includes/modules/pages/product_music_info
    ./includes/templates/template_default/templates/tpl_product_music_info_display.php
    ./includes/templates/custom_template/templates/tpl_product_music_info_display.php
    [root@boar www.giftsforgoths.com]# find -name "*product_body_jewellery*"
    ./admin/includes/languages/english/extra_definitions/product_body_jewellery.php
    ./admin/includes/languages/english/product_body_jewellery.php
    ./admin/includes/boxes/extra_boxes/product_body_jewellery_extras_dhtml.php
    ./admin/includes/modules/product_body_jewellery
    ./admin/includes/functions/extra_functions/product_body_jewellery_functions.php
    ./admin/product_body_jewellery.php
    ./includes/languages/english/extra_definitions/product_body_jewellery.php
    ./includes/languages/english/product_body_jewellery_info.php
    ./includes/modules/pages/product_body_jewellery_info
    ./includes/templates/template_default/templates/tpl_product_body_jewellery_info_display.php
    ./includes/templates/custom_template/templates/tpl_product_body_jewellery_info_display.php

    I go to the categories page in the /admin section and attempt to add a product (Product - Body Jewellery) from the list (which I can fathom is generated from the product_types table) the header displays. I can see that the code gets as far as testing what action is to be performed ie. new_product at which point it includes the collect_info.php file for the appropriate product_handler (being product_body_jewellery).

    ......

    comes back after five minutes and realises that some code I added last week to the collect_info.php page was actually going round in a loop. doh. Sorry for any inconvenience....its now displaying.

    As my colleague here always says you need a Cat to talk it through to make things clearer in your head. Thanks all the same mate.

  4. #4
    Join Date
    Aug 2004
    Location
    United Kingdom
    Posts
    32
    Plugin Contributions
    0

    Default

    One last thing, I don't suppose ZenCart has any built in functions to deal specifically with form select fields with multiple options to select? I have done a few tests and it looks like on the last value selected of say 'body_part_id' appears in the $HTTP_POST_VARS array and none of the others selected.

    Doing a quick google some people are saying that if you need to use the select input for multiple selections that you need to use the GET method to sent the data....which kinda makes this a hell of a lot more complicated than I thought :S

  5. #5
    Join Date
    Feb 2004
    Location
    Fort Collins, CO
    Posts
    21
    Plugin Contributions
    0

    Default

    Here is a little summary of what I had to do to add a new product type. This only covers the catalog section. Everything seems to be working OK. I've not tested it extensively by any means, so YMMV.


    These are the files that I had to create in order to setup a new product_magnet type. 'TEMPLATE', of course, refers to your custom template directory.

    includes/extra_datafiles/magnet_type_database_names.php
    includes/languages/english/extra_definitions/product_magnet.php
    includes/languages/english/product_magnet_info.php
    includes/languages/english/TEMPLATE/product_magnet_info.php
    includes/modules/pages/product_magnet_info/header_php.php
    includes/modules/pages/product_magnet_info/jscript_main.php
    includes/modules/pages/product_magnet_info/main_template_vars.php
    includes/modules/pages/product_magnet_info/main_template_vars_attributes.php
    includes/modules/pages/product_magnet_info/main_template_vars_images.php
    includes/modules/pages/product_magnet_info/main_template_vars_images_additional.php
    includes/templates/TEMPLATE/templates/tpl_product_magnet_info_display.php

    1. includes/extra_datafiles/magnet_type_database_names.php

    Code:
       define('TABLE_PRODUCT_MAGNET_EXTRA', DB_PREFIX . 'product_magnet_extra');
       define('TABLE_MAGNET_PLATE', DB_PREFIX . 'magnet_plate');
       define('TABLE_MAGNET_GRADE', DB_PREFIX . 'magnet_grade');
    These three definitions are tables that I created in my database. Only the first definition is necessary. It, among other things, holds the id references for the other tables. The other two tables contain supporting data that you will have to design and input manually. You can probably use the other tables for the music genre as templates.


    2. includes/languages/english/extra_definitions/product_magnet.php

    Code:
    define('BOX_HEADING_SPECS', 'Magnet Specifications');
    This was the only definition that I needed. Pretty self explanitory. This is the extra english text that goes on your product_info page.

    3. includes/languages/english/product_magnet_info.php
    -OR-
    includes/languages/english/YOUR_TEMPLATE/product_magnet_info.php

    Copy the file product_music_info.php from the same directory and begin editing to your taste. Don't add any extra definitions... just change the ones that are there. If you need to add more definitions, then do it in step #2.

    4. Copy the entire directory includes/modules/pages/product_music_info
    to
    includes/modules/pages/product_YOURTYPE_info/

    5. includes/modules/pages/product_magnet_info/header_php.php
    includes/modules/pages/product_magnet_info/jscript_main.php

    NOTHING TO DO!!!


    6. includes/modules/pages/product_magnet_info/main_template_vars.php

    This file needs some serious consideration. This is where you will be grabbing all of your special information from the DB regarding this specific product. If you are database challenged, this is going to be difficult.. but not impossible!

    Fortunately our friendly Zen Admin's have given us a good template in the product_music type. Read through it a few times.

    7. includes/modules/pages/product_magnet_info/main_template_vars_attributes.php

    Very few changes here. Only two lines changed to add the music product type.

    This line (110):
    Code:
    if (((CUSTOMERS_APPROVAL == '2' and $_SESSION['customer_id'] == '') or (STORE_STATUS == '1')) or (CUSTOMERS_APPROVAL_AUTHORIZATION == 2 and $_SESSION['customers_authorization'] != 0)) {
    Code:
    was changed to:
    if ((CUSTOMERS_APPROVAL == '2' and $_SESSION['customer_id'] == '') or (STORE_STATUS == '1')) {
    And this line (170):
    Code:
    if ((SHOW_PRODUCT_INFO_WEIGHT_ATTRIBUTES=='1' and $products_options->fields['products_attributes_weight'] != '0')) {
    was changed to:
    Code:
     
         if ((SHOW_PRODUCT_MUSIC_INFO_WEIGHT_ATTRIBUTES=='1' and $products_options->fields['products_attributes_weight'] != '0')) {
    I didn't have to change any of this since my product type doesn't use attributes.


    8. includes/modules/pages/product_magnet_info/main_template_vars_images.php
    includes/modules/pages/product_magnet_info/main_template_vars_images_additional.php

    NOTHING TO DO!!!

    9. includes/templates/TEMPLATE/templates/tpl_product_magnet_info_display.php

    This is the file to customize how the product is displayed. You will want to make sure you are displaying all of the special information out of the database.


    THE END

    Hopefully this will do more good than harm. Let me know if anything is unclear, missing, or just plain wrong. I'll try to put the instructions for the admin section up later on.

  6. #6
    Join Date
    Aug 2004
    Posts
    8
    Plugin Contributions
    0

    Default

    The last post was pretty complete, so I'll just note here that I also was able to create a new product type by a combination of duplicating files, creating new tables and hacking a couple of existing tables. I also added two new category/pick lists (like the music genre) for my product type. Unfortunately I did not keep extensive notes of what I did

    However, if you have specific questions about something that isn't working post it here or Personal Message me and I'll try and answer.

    I was also able to create the display templates for my product type and add display controls to the store configuration to show/not show my new fields.

    Then I had to hack the index page to display my fields in the listing and also hack the search code to include them in search. Once I have the whole thing the way I want it I might figure out how to abstract the addition of new search fields and submit it to the zen guys... but I have alot going on right now :)

    Mike

  7. #7
    Join Date
    Jun 2003
    Posts
    33,804
    Plugin Contributions
    0

    Default

    Basic documents have just been added to the downloads section.

    http://www.zen-cart.com/modules/mydownload...sit.php?lid=324
    Please do not PM for support issues: a private solution doesn't benefit the community.

    Be careful with unsolicited advice via email or PM - Make sure the person you are talking to is a reliable source.

  8. #8
    Join Date
    May 2004
    Location
    Lubbock, TX
    Posts
    226
    Plugin Contributions
    0

    Default

    For anybody trying to implement the zen_book_demo product type... When I was doing this I got an SQL error when trying to run the SQL included. I found that there is a comma that needs to be removed following a zero at around line 20 of book.sql.

    After this phpMyAdmin kept choking on:
    Code:
    # delete if exists
    DELETE zen_product_type_layout FROM zen_product_type_layout zptl,zen_product_types zpt WHERE zpt.type_id = zptl.product_type_id AND zpt.type_handler = 'pubs_product_book';
    I tweaked several things in there but could not get it to pass. Finally I deleted the fields by hand in phpMyAdmin and commented the above command out of the file. If anyone has any further insights on this issue, please share. I have not had time to test to see if all this is working yet (with the Book product type demo). I thought I'd post this here since this seems to be the most active thread about adding/creating product types right now.

  9. #9
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,403
    Plugin Contributions
    6

    Default

    More than likly it is the prefix reference on the table of zen_ that needs to be removed.
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  10. #10
    Join Date
    Aug 2004
    Posts
    80
    Plugin Contributions
    0

    Default

    Just FYI.. the 0.2 version of the book product_type demo has a bug in the update_product.php file. v0.3 fixes it and should be downloadable in a few days.

    If you want to fix it yourself.. just go to the last line and uncomment the commented out redirect.

    http://www.zen-cart.com/modules/mydownload...wcat.php?cid=41

 

 
Page 1 of 15 12311 ... LastLast

Similar Threads

  1. Is there a way of adding a product but stopping it from adding to new products?
    By philpalmerdevon in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 19 Jan 2009, 02:07 PM
  2. When adding new parts, adding part number to preview screen
    By GTHENRY in forum Basic Configuration
    Replies: 1
    Last Post: 18 Jun 2008, 07:53 PM
  3. product_types.php details
    By MarkRS in forum Setting Up Categories, Products, Attributes
    Replies: 12
    Last Post: 30 Sep 2006, 06:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR