Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2011
    Posts
    121
    Plugin Contributions
    0

    Default Creating custom attribute types?

    Hi,

    At a basic level, which files will I need to edit to add in a new type of attribute? For example, a second style of drop down? I have currently modified the attribute module, and template to get a radio button style attribute to show as a selectable image swatch, but realised we may still need to use the radio button for other options. I assume some files on the admin control panel, the attributes module and template to handle the type, but also is there somewhere after the user clicks on "Add to Cart" ?

    Thanks!


    More info:

    I am working on a zen cart system for a client.

    The plan is to create a "Personalise" option where a section pops up where the user will be able to select fonts, thread colour, type initials, and have it render using an API we have access to which produces an embroidery effect on the product.

    Most of this is fine, how ever I will need to create additional attribute types, so almost like "Dropdown", I will have to create one that says "Font select", but needs to display differently to the normal drop down menu.

  2. #2
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: Creating custom attribute types?

    So the question about which files to modify is typically best "self" asked... I am not trying to be a pain about it, but the base ZC files could be identified and still not address all of the files that need modification.

    Attribute types are essentially identified/defined in the database. To first add a new attribute type, would need to add it to the "list". From there, the product's attributes would need to be evaluated where they are used to support taking action on/associated to the applicable attribute type.

    Take note of how the includes/modules/attributes.php file evaluates what attribute type is being considered. There are constants that are used in the evaluation. Those constants are defined in the database. A new product type would need to be evaluated the same way. Lat9 has proposed some suggestions of how the attributes.php file could remain intact but also address a new attribute type. (http://www.zen-cart.com/showthread.php?215869 refers) implementation of that method would require a little bit of homework to understand how to implement notifier/observer style action, but if incorporated would beef up the use of attributes without modification of the file.

    So, for example to find all occurrences of the radio button usage, one could look for PRODUCTS_OPTIONS_TYPE_RADIO using the Developers Toolkit (DTK) to identify all the files in which the comparison has been made to the attribute type of radio. Thing is, not likely to find a similar comparison for dropdown attribute types. If you look at how the attributes file above is structured, comparisons are made for all other attribute types, but if none of them are identified then the attribute is considered to be a dropdown. One caveat, if there is only one item in this "dropdown" then the attribute is treated like a radio button.

    So not exactly a solution, but should help.

    Maybe could also look at how some other plugins create attribute types.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Aug 2011
    Posts
    121
    Plugin Contributions
    0

    Default Re: Creating custom attribute types?

    Thanks for your reply.

    Sounds quite complicated to do this.

    I have currently changed the way that the radio buttons display to be able to display a colour swatch instead, the radio buttons are still there just hidden, and selecting the colours will select the radio buttons with jquery. The trouble is that any other radio button attributes are hidden.

    I guess I should start at looking to make a duplicate radio button style attribute.

    You mentioned that the attribute types are defined in the database, but I can't see that.
    Last edited by joecooper; 12 Mar 2015 at 11:41 AM.

 

 

Similar Threads

  1. v154 Creating new product types help :(
    By DannyVarley in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 26 Jan 2015, 01:41 PM
  2. Additional Attribute Types
    By thomkolton in forum General Questions
    Replies: 5
    Last Post: 17 Apr 2011, 05:25 AM
  3. custom product types
    By tokkie in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 2 Feb 2010, 07:57 PM
  4. No Attribute Option Types...
    By Alex Clarke in forum General Questions
    Replies: 10
    Last Post: 12 Aug 2006, 08:56 PM

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