kongondo

FieldtypeVariations: Upcoming Pro Module for Product Variations & Attributes

12 posts in this topic

Introducing Variations, an Input- and Fieldtype for product variations and their attributes.

Product variations is a topic that has been coming up now and then, especially in the recent past.  This module seeks to fill this gap. Though it's in its early stages of development, it is already functional and can be used as is. I decided to make an early announcement (modules development forum) in order to get early feedback from potential users. 

The module is an alternative take on how variations can be built for a product. Imagine the ubiquitous T-Shirt. The product could vary by ...Size, Colour, Material, etc...These variations could in turn have internal variations, i.e. attributes....so, Size [Small, Large], Colour [Red, Blue]...etc; you get the drift.

The usual approaches to building variations have been either to use Multiple pages, Repeaters, Page Table, Table or Matrix (limited to 1x1 variations). In this module, we do it a bit differently.

First, the variations occur not at the Field level (meaning all product pages would have the same variations and attributes for each template) but at the page level. Secondly, there are no multiple pages for each variation and/or attributes; a product is a single page. The variations and their attributes are defined by site editors at the page level. Once a variations configuration has been defined, it is applied to the page and all possible combinations are generated (i.e. the Red,Small,Cotton; Red,Large,Cotton, etc) in the Inputfield. There is no limit to the number of variations and attributes that can be defined, although you will be amazed at how quickly the combinations grow! Prices are entered for each combination when editing the page. Combinations without prices are not saved to the database. Please note that prices cannot themselves vary at the page-level. Meaning, you cannot have ONE variation configuration that has different price inputs per product in the same FieldtypeVariations field.

The module ships with an API for outputting variation combinations in the frontend. Search, database and in-memory work as normal in the frontend. In the backend, DataTables provides a nice paginated, filterable table. Prices can be entered on any pages (of the table) without loss of data (meaning you can enter prices on page 1, scroll to page 10, enter more prices, filter or search the products table, enter more prices and finally save; no data will be lost).

I still have a couple of ideas and plans pending but would love to hear from you, thanks.

Below is a short video demo of the module in its current state. Things may/will change, both UI and features. Btw, the Fieldtype, although primarily targeted at commerce applications, is by no means limited to this. Other uses requiring combinations of whatever number of variables are very much within the remit of the module.

Planned/Hoped for features

  1. Import/Export product variations and attributes (Excel, etc)
  2. Full integration with Padloper (I will have to  discuss with @apeisa)
  3. SKU fields for each product variation
  4. Add/Remove extra subfields, e.g. multi-currency prices (currently there is only 1 input for each product variations' price)
  5. Product variation images?
  6. Etc...

Please not this module is not related to this other planned module (but it may eventually).

Sneak Peek Demo

 

 

Edited by kongondo
9 people like this

Share this post


Link to post
Share on other sites

Sounds very interesting!

47 minutes ago, kongondo said:

Combinations without prices are not saved to the database.

47 minutes ago, kongondo said:

Btw, the Fieldtype, although primarily targeted at commerce applications, is by no means limited to this.

Does this mean the "Price" field is only an example, and in non-commerce situations you could add some other type of field to store data related to the variation? Will you be able to add multiple data fields to the variations?

1 person likes this

Share this post


Link to post
Share on other sites
27 minutes ago, Robin S said:

Does this mean the "Price" field is only an example, and in non-commerce situations you could add some other type of field to store data related to the variation?

Yes, e commerce being the most likely use for this module.

Just to be clear for the sake of others, technically, these are subfields. E.g., price is a subfield (meaning a database column in a FieldtypeVariations field [technically a database Table] which you access as $variationsfield.price, similar to $page->image.description).

Back to your question, this is a planned feature (although code is already in place). Please note that, in respect of these subfields, there are no plans to include anything as near exhaustive as what Table does. Meaning, these will likely be limited to TEXT, INT, FLOAT, etc fields, but not complicated Fieldtypes such as Page fields, Repeaters, etc. 

 

27 minutes ago, Robin S said:

Will you be able to add multiple data fields to the variations?

Yes, as many or as little as you want, pre or post-field use. For instance, start with price (default but in future versions one will be able to remove the subfield), then later or at field configuration add an SKU subfield, a discount subfield, some text subfield, etc. 

Edited by kongondo
3 people like this

Share this post


Link to post
Share on other sites

I am thinking of changing the way variations +  attributes are created and applied. Currently, these have to be typed whenever one needs them. For different products that share an attribute (e.g. 'Red') but not necessarily a variation configuration, all that typing is repetitive. For instance, the colour Red means the same thing irrespective of whether it is a Car or a T-Shirt or a Phone. If you have all these products for sale, you should be able to just select colour from some list you previously typed and be presented with all colours from which you can select which apply to your product. Meaning, at the product/page configuration level, you will first have to select the variations you want, e.g. Size, Colour, Material, etc....then select the respective values/attributes, e.g. Yellow, etc. Small, etc.

1 person likes this

Share this post


Link to post
Share on other sites

This looks really nice! I agree having the page as context is a smart move! Hadn't thought of the problems of having that represented at field level. I also REALLY like the idea of variations existing on its own as presets somewhere else. 

Something that I see solved nicely and horrible at the same time, is Shopify's very own variation editor is batch edition of prices and variation names.

Eg. Select a variation by one of its properties and change the price in a batch table mode. This was done pretty nicely in an Excel like fashion, or multi checkbox select and command in menu.

What I did suffered was making a soccer uniform shop with 10+ sizes and sometimes 20+ variations in color. An error in creating the names would imply to REDO all the variations, or go through a menu to edit EACH variations name. Always almost easier to recreate the whole thing. It seemed as if after creating the list of variations per property in a nice interface, they all lost the relationship amongst them. So if you had written Brgundy / Dark Blue, get ready to edit +50 fields in modals or just delete the whole thing. There goes your day!

And the variations problem reveals a  flaw in Shopify's service, no more than 100 product variations. Why I might guess won't be a problem for PW.

I think variations images would also be quite the deal!

Nothing more to add, just personal experiences of suffering from product variations. Hope to see this released!

1 person likes this

Share this post


Link to post
Share on other sites

Hi all,

Quick update. I finished the first release of this module nearly two weeks ago. However, I have not yet had the time to finish the documentation and clean it up a bit nor produce a demo. I'll see if I can squeeze something in this week, but doubtful.  Current features are:

  • Fully integrated with Padloper! This was easier than expected. Thanks to Hooks, I didn't have to lift a finger. Please note that you will have to write the Hooks code yourself. We'll give you examples (very similar to this in Padloper docs).
  • Dynamically add or remove subfields. Price is no longer the default; there is no default. When creating the a Variations field, you create the subfields/columns you want (e.g. Price, SKU, Remarks, Price 2, Discount Codes, whatever...!
  • Attributes are created separately from the variations. For instance, you can create the attribute Colour and add as many colours to it as we you want. Colour will then be selectable (add one or all, remove one or all) when creating a variation configuration. Once you select colour, all the colours in it are auto-populated in a dropdown, ready for selection. This means that you can choose some colours for one product and choose different set of colours for another.

The above will be clearer in the demo. Just wanted to let you know that this is ready...:).

Edited by kongondo
More info

Share this post


Link to post
Share on other sites

Hi @kongondo

I have started a project with Padloper, and I'm thinking to wait for your module, but want to know about price and the maximum term of release date.

Could you please provide some info? 

Share this post


Link to post
Share on other sites
1 hour ago, Zeka said:

I have started a project with Padloper, and I'm thinking to wait for your module, but want to know about price and the maximum term of release date.

I'm hoping maximum 2 weeks, 3 at the most before an official release. It will be priced similar to my other modules (but could be subject to change).

Thanks for your interest.

Share this post


Link to post
Share on other sites
28 minutes ago, Zeka said:

Is there any news about your module? 

Working on it as we speak. Other stuff got into the way and had to shelve it for a while. Like I said though, the module is ready, just working on the documentation and some final checks.  I am hoping for a release next week. 

4 people like this

Share this post


Link to post
Share on other sites

Variations 001 has been released! 

Please see its official support thread here.

Thanks for your patience! This thread is now closed.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Robin S
      First a note about my other modules...
      I have three existing modules that are similar in that they allow restrictions to be placed on repeating inputfields: Limit Repeater, Limit PageTable, Limit Table
      Restrict Repeater Matrix takes a different approach to the module configuration from those other modules. The module settings for Restrict Repeater Matrix are applied in the field settings rather in a module config screen. I think this new approach is better, but it means that it isn't practical to create different settings for different roles via the admin interface. Instead the module has a hookable method, allowing roles to be targeted and other advanced usages to be achieved via a hook. The result is that the module is more flexible.
      I intend to transition my other modules to the same approach over the coming weeks, but because this will result in breaking changes I will be releasing the updated modules under new names ("Restrict Repeater", etc) to avoid users upgrading via the Upgrades module without full awareness of the changes. The old modules will be marked as deprecated.
       
      Restrict Repeater Matrix
      A module for ProcessWire CMS/CMF. Allows restrictions and limits to be placed on Repeater Matrix fields.
      For any matrix type in a Repeater Matrix field you have the option to:
      Prevent drag-sorting of items Prevent cloning of items Prevent toggling of the published state of items Prevent trashing of items Limit the number of items that may be added to the inputfield Please note that restrictions and limits are applied with CSS/JS so should not be considered tamper-proof.
      Usage
      Install the Restrict Repeater Matrix module.
      For each matrix type created in the Repeater Matrix field settings, a "Restrictions" fieldset is added at the bottom of the matrix type settings:

      For newly added matrix types, the settings must be saved first in order for the Restrictions fieldset to appear. Set restrictions for each matrix type as needed. A limit of zero means that no items of that matrix type may be added to the inputfield.
      Setting restrictions via a hook
      Besides setting restrictions in the field settings, you can also apply or modify restrictions by hooking RestrictRepeaterMatrix::checkRestrictions. This allows for more focused restrictions, for example, applying restrictions depending on the template of the page being edited or depending on the role of the user.
      The checkRestrictions() method receives the following arguments:
      $field This Repeater Matrix field $inputfield This Repeater Matrix inputfield $matrix_types An array of matrix types for this field. Each key is the matrix type name and the value is the matrix type integer. $page The page that is open in ProcessPageEdit The method returns a multi-dimensional array of matrix types and restrictions for each of those types. An example of a returned array:

      Example hooks
      Prevent the matrix type "images_block" from being added to "my_matrix_field" in a page with the "basic-page" template:
      $wire->addHookAfter('RestrictRepeaterMatrix::checkRestrictions', function(HookEvent $event) { $field = $event->arguments('field'); $page = $event->arguments('page'); $type_restrictions = $event->return; if($field->name === 'my_matrix_field' && $page->template->name === 'basic-page') { $type_restrictions['images_block']['limit'] = 0; } $event->return = $type_restrictions; });  
      Prevent non-superusers from trashing any Repeater Matrix items in "my_matrix_field":
      $wire->addHookAfter('RestrictRepeaterMatrix::checkRestrictions', function(HookEvent $event) { $field = $event->arguments('field'); $type_restrictions = $event->return; if($field->name === 'my_matrix_field' && !$this->user->isSuperuser()) { foreach($type_restrictions as $key => $value) { $type_restrictions[$key]['notrash'] = true; } } $event->return = $type_restrictions; });  
      https://github.com/Toutouwai/RestrictRepeaterMatrix
    • By bernhard
      Hi,
      just stumbled over a little module that i built for my last project. it helped me to test performance of my rockdatatables module to generate 3000 random json datasets and i want to share it with you. maybe it saves some time for someone.
      https://gitlab.com/baumrock/RockDummyData/
      easy example:
      $rdd = $modules->get('RockDummyData'); for($i=0; $i<15; $i++) { // this has to be inside the for-loop to always get a new dummy $dummy = $rdd->getDummy(); echo date("d.m.Y H:i:s", $dummy->timestamp) . "<br>"; } more advanced:
      $json = new stdClass(); $json->data = array(); $rdd = $modules->get('RockDummyData'); for($i=0; $i<3000; $i++) { // this has to be inside the for-loop to always get a new dummy $dummy = $rdd->getDummy(); $obj = new stdClass(); $obj->name = $dummy->forename . ' ' . $dummy->surname; $obj->position = $dummy->job; $obj->office = $dummy->city; $obj->color = $dummy->color; $obj->start_date = new stdClass(); $obj->start_date->display = date('d.m.Y',$dummy->timestamp); $obj->start_date->sort = $dummy->timestamp; $obj->salary = rand(0,10000); $json->data[] = $obj; } echo json_encode($json); you have to store your random datasets on your own into the /data folder. there are several services for creating all kinds of random data on the web - if you know one service that allows sharing those datasets let me know and i can include common needed data into the module
    • By AndySh
      Hello!
      I need your assistance please. I purchased the module FormBuilder. Unfortunately, the module discontinued delivering customer submissions to e-mail box specified in the module settings. Direct mailing to the e-mail box works OK. The module settings stays the same and are correct, like "Send e-mail to administrator(s) is checked. The last version of FormBuilder 3.0 has been installed. Please advise how to resolve the issue becase I cannot get orders from customers anymore (((
    • By kixe
      As described in this post (https://processwire.com/talk/topic/8551-custom-urls-for-pages/?p=82742) the option 'Name Format Children' under the tab 'Family' in template settings doesn't work properly and also not as expected. I had a look inside the code and made some changes which are working properly, which offers much more options, more consistency and less code too.

      The result is the following. You have 3 Options for generating name and title, which could be combined in endless variations.
      Name is always derived from title, same like creating pages manually.
      type date: if function detects # character anywhere in the string, conversion will be: deletion of # and string will be used as format parameter for PHP date() function type field: if string is a fieldname of the parent page the value of this field will be used type string: if string doesn't fit to the 2 preceeding it will be taken as it is All parts (separated by comma) will be composed in the order of setting. You can use unlimited numbers of parts

      I made a pull request on github: https://github.com/ryancramerdesign/ProcessWire/pull/831

      Example screenshots

      Setting ...


      will result in


       
    • By kongondo
      FieldtypeRuntimeMarkup and InputfieldRuntimeMarkup
       
      Modules Directory: http://modules.processwire.com/modules/fieldtype-runtime-markup/
      GitHub: https://github.com/kongondo/FieldtypeRuntimeMarkup
       
      This module allows for custom markup to be dynamically (PHP) generated and output within a page's edit screen (in Admin).
       
      The value for the fieldtype is generated at runtime. No data is saved in the database. The accompanying InputfieldRuntimeMarkup is only used to render/display the markup in the page edit screen.
       
      The field's value is accessible from the ProcessWire API in the frontend like any other field, i.e. it has access to $page and $pages.
       
      The module was commissioned/sponsored by @Valan. Although there's certainly other ways to achieve what this module does, it offers a dynamic and flexible alternative to generating your own markup in a page's edit screen whilst also allowing access to that markup in the frontend. Thanks Valan!
       
      Warning/Consideration
      Although access to ProcessWire's Fields' admin pages is only available to Superusers, this Fieldtype will evaluate and run the custom PHP Code entered and saved in the field's settings (Details tab). Utmost care should therefore be taken in making sure your code does not perform any CRUD operations!! (unless of course that's intentional) The value for this fieldtype is generated at runtime and thus no data is stored in the database. This means that you cannot directly query a RuntimeMarkup field from $pages->find(). Usage and API
       
      Backend
      Enter your custom PHP snippet in the Details tab of your field (it is RECOMMENDED though that you use wireRenderFile() instead. See example below). Your code can be as simple or as complicated as you want as long as in the end you return a value that is not an array or an object or anything other than a string/integer.
       
      FieldtypeRuntimeMarkup has access to $page (the current page being edited/viewed) and $pages. 
       
      A very simple example.
      return 'Hello'; Simple example.
      return $page->title; Simple example with markup.
      return '<h2>' . $page->title . '</h2>'; Another simple example with markup.
      $out = '<h1>hello '; $out .= $page->title; $out .= '</h1>'; return $out; A more advanced example.
      $p = $pages->get('/about-us/')->child('sort=random'); return '<p>' . $p->title . '</p>'; An even more complex example.
      $str =''; if($page->name == 'about-us') { $p = $page->children->last(); $str = "<h2><a href='{$p->url}'>{$p->title}</a></h2>"; } else { $str = "<h2><a href='{$page->url}'>{$page->title}</a></h2>"; } return $str; Rather than type your code directly in the Details tab of the field, it is highly recommended that you placed all your code in an external file and call that file using the core wireRenderFile() method. Taking this approach means you will be able to edit your code in your favourite text editor. It also means you will be able to type more text without having to scroll. Editing the file is also easier than editing the field. To use this approach, simply do:
      return wireRenderFile('name-of-file');// file will be in /site/templates/ If using ProcessWire 3.x, you will need to use namespace as follows:
      return ProcessWire\wireRenderFile('name-of-file'); How to access the value of RuntimeMarkup in the frontend (our field is called 'runtime_markup')
       
      Access the field on the current page (just like any other field)
      echo $page->runtime_markup; Access the field on another page
      echo $pages->get('/about-us/')->runtime_markup; Screenshots
       
      Backend
       

       

       
      Frontend