http://modx-shopkeeper.ru/


Translated by kp52.

SHKwidget snippet for MODx

Description

Snippet to create widget parameters (drop-down lists, radio buttons, checkboxes) for goods in the internet store. Use in conjunction with Shopkeeper snippet.
Use only on the product page. When displaying lists of products with Ditto, use the SHKwidget extender (eng_doc_ditto_extender.html).

Installation

  1. In the Manager, go to
    Elements -> Manage Elements -> Snippets (MODx 1.x) or
    Resources -> Manage Resources -> Snippets (MODx 0.9.x)
  2. Click on "New Snippet".
  3. Snippet name: SHKwidget,
    Description: Widgets for Shopkeeper,
    Open the file SHKwidget_snippet.php in the "install" folder, copy the contents and paste into the "Snippet Code" field. Click "Save".
  4. Create a template variable for the parameter with the type "Textarea" or "Text", e.g. "param1".
  5. When adding and updating products, parameters are entered in the following format:
    Parameter1==Value1||Parameter2==Value2||...

    Example (first value empty):
    ==||Gift wrap==3.50||Gift bag==5.00

    For a checkbox: Delivery==15

    Parameters with a value of zero can be entered. This is useful for parameters (such as colour) that do not influence the price. For example: blue==0||green==0||red==0

Snippet parameters

&docid - id of the document that the parameter TV is intended for (default ID of the current page);

&format - type of element to be created. Possible values: select, radio, checkbox, radioimage (default: `select`);

&tvname - name of the parameter TV;

&first_selected - select first value of the element (`1`) or not (`0`) (default: `0`);

&wraptag - wrap in an HTML tag. May be any HTML tag, such as `div`. Value of `0` (default) means no wrapping.
Can be used for radio buttons and checkboxes;

&function - JavaScript function to be invoked on selection. Default - `jQuery.additOpt(this)`.

Sample call

[[SHKwidget? &format=`select`&tvname=`param1`]]

Create a list of available colors, materials, etc. (&format=`radioimage`)

Type (format) Widget radioimage is used for visual presentation of a list of available colors or materials for the goods. Pictures of colors, materials, etc. loaded with TV-image, while editing products, you can choose from the list.

  1. Create a section in the document tree, such as "Materials". ID of this section (in parentheses) will need later.
  2. In this section, create for each material (or color, etc.) a separate page. For all materials you need to enter their name (title).
    If this section is not TV with the type of input "Image", create it (note the ID, which is listed in parentheses after the title). Upload a picture for each material.
  3. Create a new TV-setting. "Elements" -> "Manage Elements" -> "Template Variables" -> "New Template Variable".
    • Template Variable Name: such as "material" (unquoted).
    • Caption: such as "Fabric".
    • Input Type: Listbox (Multi-Select)
    • In the field Input Option Values Enter a query:
      @SELECT cnt.pagetitle, tvc.id FROM modx_site_content cnt, modx_site_tmplvar_contentvalues tvc WHERE cnt.id = tvc.contentid AND tvc.tmplvarid = 4 AND cnt.parent = 48
      where 4 - TV-pictures ID, 48 - ID section with pages of material.
    • Widget: Delimited List
        Delimiter - "," (comma without quotes).
  4. In the block "Template Access" select the template of goods (to TV was available when editing products).
  5. Click "Save." Now, for each product you can choose the material (or color, etc.) from the list. To select multiple items use the CTRL or SHIFT.

Example snippet call SHKwidget template Product:

<div class="materials">[[SHKwidget? &format=`radioimage`&tvname=`material`&first_selected=`1`]]</div>