Options

Option values

Options give the customer the ability to choose the product variant he needs. For example, the size and/or color:

In this case, the product has the "Size" option, which has several values to choose from.

Unlike attributes, option values have a price and quantity, and are added to the product not as text, but by their number - option_id. That's why:

  • changing the option value in the OpenCart admin panel (for example, "Red" to "red") will change this value simultaneously in all products:

  • it is impossible to enter a new option value in the product without first creating it in the "Options" admin panel section

The plugin can create an option value automatically before it adds that value to the product.

The term "Create" used in the plugin, in relation to options, means creating the option value, not the "Size" or "Color" option itself:

Option price

Each option value has a price, relative to the product price, i.e. plus or minus to the product price. For example, if the product price is 100 and the price of the value "Red" is +10,

when buying the Red option the price of 110 is added to the cart

By default, OpenCart does not allow option price =100. When buying, it will add it to the product price and the price of 200 will be added to the cart.

The plugin can add both absolute (=110) and relative (+10) option prices. This can be set in the supplier's form first tab "Common Buttons":

Notice.

First, the plugin adds the option prices as "equal to" (=110) and when all the product options are loaded, the plugin recalculates the prices as "plus" to the product price.

If the product price is equal to the option price, the option price will become +0

This happens when the column number with the product prices in the price list matches the column number with the option prices i.e. when the product price is equal to the option price.

The product price can be set by the plugin as the minimum among the option prices. Then all relative option prices will be prefixed with "+".

If option and product prices are in different columns, then the product price will be set according to the last product price in the respective column.

However, this rule can be changed:

Option quantity

The sum of all product option quantities becomes the product quantity. Whatever product quantity is loaded from the price list, it will be changed by the plugin after the options are added.

If options were added or updated with the "Subtract Stock" button enabled:

option values with zero quantity will not be displayed on the product page.

Related options

More precisely, different options with related values.

For example, if a certain product has in stock red color, size XS and quantity 4 pcs. at a price of 100, we can say that the value "red" is related to the value of "XS".

When there are related options on the site, and the client selects one of them, the values of the other option are limited only to the available ones.


Product Option as Product (New Line)

One of the most common ways to represent options in a price list is when a product is repeated in price list rows with different option values.:

as evidenced by the repetition of "sku" in column #1.

In our example, there are 4 products, and each of them has one or more "Color" option values (column 3). Each option value has a price and a quantity (columns 5 and 6).

The product price and quantity are not shown in separate price list columns, therefore, the product price will be determined from column 5 as the minimum among the option prices, and the quantity - as the sum of the option quantities from column 6.

Options import and update algorithm

The product, in the second line, with SKU mantis_1900245 can be imported if this SKU is missing on the site and the add mode is enabled ("Add and update"). Therefore, this line should contain information about the product name, price, image, and at least one category. The product will be created with one "Color" option value - White.

Lines 3, 4, and 5 represent the same product mantis_1900245, which was already created in line 2, which means that the product will be updated three times. During the update, the values of the option "Color" will be added to the product: Orchid and Platinum.

In line 6, the SKU has changed. The plugin considers this as the end of product mantis_190024 data. At this point it:

  • finds the minimum price among the options and sets it as the product price: 10
  • calculates the option values relative prices as a plus to the product price: +0, +0.50, +0.85, +0.60
  • sums all option values quantities and sets this amount as product quantity: 12

Setings

1. SKU

The SKU is in column #1 and specifies a product. If SKUs specify options, then the SKUs in column 1 would all be different (see "Option with SKU").

2. Product price and quantity

The product price and quantity will be recalculated by the options. For example, the price of the last item (sku mantis_1900263) will become 11, and the quantity will be 9 pcs.

For the option prices to be imported and become relative, as a plus to the product price, enable this button:

and set the general rules for option import (see "General buttons").

3. Options tab

The field "SKUs separated by a semicolon. Column number" is not required. This field is used only if each option has a separate SKU.

Field "Option quantity. Column number". You can add multiple column numbers separated by commas. In this case, the quantity will be equal to the sum of the contents of these columns.

If the "Option quantity" field is left blank, all option values quantities will be set to the default 9.

The "Prefix" select should be set if the option prices in the price list are relative. For example, "plus price", and this fact is not marked with "+":

Prefix

  1. The price prefix is set by the option prices in the price list.
  2. Prices in the price list should be interpreted as a plus to the product price +
  3. The prices in the price list are a markup to the product price in percent %
  4. The prices in the price list are a discount on the product price in percent #
  5. The number in the price list is a multiplier of the product price *

"Nullify missing option values" button

For option values that are not on the price list, the quantities will be reset to zero:

Attention: Enable this button only when the product is presented in the price list in adjacent lines, as in the examples above. Otherwise, for example, in this case:

the option to be added or updated in the product mantis_1900245 on line 7 (see yellow lines) will reset all previous options:


One Product One Line (options in cells)

In this price list format, the product including its options is on one line. It is in this format that the plugin exports products with options:

In this example, we have 5 products with SKUs in column 1 and the "Color" option in column 6. Product prices and quantities are in columns 3 and 4, and option values prices and quantities are in separate columns 5 and 7.

Option values are separated by semicolons. The same symbol separates prices and quantities in columns 5 and 7.

The following characters can be used as a separator:  

 ; | : /

If a different separator is used in the price list, then it can be added to the module code in the admin/model/catalog/suppler.php file. In two places, after the lines: $ss = '/';

uncomment /* */ the code and replace the "comma" character with another one.

Supplier's form settings

Columns 5 and 7 (see the image above) cannot be used for product price and quantity, because their content is not a number. At the same time, the "Product price" and "Product quantity" are required in the supplier form.

Fortunately, there are such columns in this price list - these are columns 3 and 4:

The result of such a setting, using the example first product will be:

  • product price: 9
  • option values and prices: big +0, middle +1, small +2
  • product quantity: 10+12+14 = 36

If these columns (3 and 4) are missing, you have to enter arbitrary numbers in the supplier form, set the quantity by default, and use the "Set price by minimum option" button for the price:

The result of such a setting, using the example first product will be:

  • product price: 9
  • option values and prices: big +0, middle +1, small +2
  • product quantity: 10+12+14 = 36

The product quantity was set to 9 by default, because if the quantity is 0 the product price is not updated. Then the plugin recalculates the correct product quantity as the sum of the options quantities.

Products in rows 2 and 3 will only be added or updated if there is a price for the item in the price list since option prices are in addition to that price.

Options tab settings:

"General buttons" settings:


Option with SKU

OpenCart assumes that products with different SKUs are different products.

The plugin searches for a product by SKU (SKU field) and if it finds it, it can update it, including options, attributes, images, description, price... everything that you have set to be updated.

The SKU specifies a product

If there are several lines with the same SKU in the price list, the plugin will update the product as many times as the SKU repeats. For example, a price list with 2 products:

If options are specified in the product lines (column "color"), then the plugin will sequentially add these options to the product if you allow it in "General Buttons":

And set the processing action to product update mode.

As soon as the article in the price list changes (see line 6), the plugin will "understand" that a new product has started and it's time to sum up the previous one.

The SKU specifies an option

Here is a price list example where the SKU is associated with the option value and not with the product:

In this case, the plugin cannot separate one product from another and will process all rows as 6 different products with SKUs from column 1.

Without additional settings in add mode, not 2 products with options will be added to the store, but 6 different products.

Supplier's form settings

To process this kind of price list, the plugin needs special settings:

1. SKU

The SKU in column 1 is not the product SKU, but the option value SKU. The product SKU has to be present and can be arbitrary. But unique.

2. Grouping multiple price list lines into one product with options.

"repeating product indicator" is only used when adding new products to the store.

In case the price list is missing the product SKU and only the option SKUs are available, you have to manually add a repeating product indicator.

In column 7, the number 1 is added in those lines that are a product continuation from the previous line. In the line where the product begins, the repetition flag is not set:

"Repeating product indicator" can be any character, even a space.

The plugin stores the options SKUs in the product, in the "Options" tab "SKU" field:

The field option "SKU" is not an OpenCart default field, it is added when installing the plugin (in the database: table product_option_value field optsku).

Adding products with SKUs in options

1. Unfortunately, to add new products with SKUs in the options, you have to change the original price list. It is necessary to create and fill in the column "Repeating product indicator". Write down its number in the supplier's form.

2. Enable the button "SKU specifies: Option".

3. Set Options tab.

4. Set Action to "Add and update".

5. Save the supplier form and start the price list processing.

Updating products with SKUs in options

As usual, a price list with three columns is enough to update prices and quantities:

  • SKU
  • Price
  • Quantity

1. The "Repeating product indicator" field can be left blank.

2. Enable the button "SKU specifies: Option".

3. Set Options tab.

4. Set Action to "Update only".

5. Save the supplier form and start the price list processing.

The updating options with SKUs setting has one important detail: you need to prevent the plugin from creating option values in products. To do this, on the supplier form main page in the "General Buttons" you have to set:

and in the tab "Options" refer to the empty price list column in the field "Value":

This will prevent the plugin from creating an empty option value in the product.


Options. Export Import

Product with options export is commonly used to transfer products from site to site.

Export

The plugin exports products to a tabular price list (XML Spreadsheet 2003), file admin/uploads/ex.xml in "one product - one line" format.

There are slight setting differences for importing products with SKU in options from a file created by the plugin. This is because the plugin exports option SKUs into a single cell with a semicolon separator:

Column 3 contains the SKUs of M, S, and L values of the "Size" option, and column 1 has the product SKU.

Import

1. Product SKU on the supplier's form main page:

Note the "SKU specifies" button is set to "Product".

2. You have to set options import rules in the "General Buttons" section:

3. "Options" tab:

The only case where the field "SKUs separated by a semicolon" is used.


Option. Image

Each option value can have one or more images. Images can only be uploaded from a link in the price list.

All images for each option value have to be placed in one price list cell and separated by "semicolon" and/or "comma":

Column 5 contains image links for different "Color" option values. Some values have two images, and some have one. Line 11 shows the image file names in the image/catalog/temp folder

In the supplier's form settings in the "Options" tab, it is enough to enter the column number with the image:

The price list fragment in the first image can be used to demonstrate the difference between default OpenCart and a third-party module working with option images.

OpenCart standard

Two products have the option value White. The plugin will first assign the line 2 product option image to the option value "White". Then when processing the next lines will replace it with the line 10 product option image. According to the OpenCart standard, the option value White can have one image that will be used for all products.

Working with option images in standard Opencart involves using small monochrome images rather than full-fledged products images

To upload images according to the OpenCart standard, use this setting:

In the "General Buttons" section on the supplier's form main page.

Options images and third-party OpenCart modules.

Here, option images are linked not only to the option value name but also to the product. Therefore, different products may have different option images for the same White value.

The module "Options images PRO, allows you to assign several images to one option value (comma-separated in the price list, see the first image).

Usually, third-party modules record the option image into the product_option_value table in a custom field. If you fknow the name of this field (usually: "image") and enter it in the file admin/model/catalog/suppler.php in this place:

after line:  if ($upOptionFoto == 4) { it will be possible to upload option images using this setting:

Single line options

If the options in the price list are presented on a single line with separators, then the options images have also be placed on the same line. Here is an example when the option value has only one image:

Different option values images have to be separated by a semicolon, regardless of which character separates option values, prices, and quantities.

If each option value has several images, these images have to be separated by a comma. The image below shows the general scheme:

It is in this format that the plugin exports the product options.


Related Options

The different option values in a product can be related. For example, a size 46 red t-shirt has the related values "red" and "46".

In OpenCart, all options are independent, which means that if you do not use a third-party module, the number of products during import will increase twice: 5pcs "red" + 5pcs. "46" total 10 T-shirts. In addition, OpenCart will allow you to choose a t-shirt in size 46, white, which is out of stock.

We recommend the module " Related Options".

Related options in the price list

The plugin considers option values as related if they are in the same line of the price list and have a common "Quantity" column:

If in the "Options" tab settings, the same column 5 is set for the "Color" option quantity and the "Size" option quantity:

the plugin will process these options as related.

After processing such a price list by the module, in the product mantis_1900245 there will be 4 choices:

  • color White - size  X
  • color Orchid - size  L
  • color Platinum - size  M
  • color Platinum - size  XL

and the Related Options module will ensure that other color and size combinations cannot be selected.

Related Options module troubleshooting

The plugin creates its own related options table in the database, and, in theory, should only display data from this table on the site.

But unfortunately, it also uses data from the standard OpenCart options table:

which often contradict data from the related options table.

You can correct this conflict by cleaning the OpenCart options table with this tool:

after the product update from the price list.

Or include in the admin/model/catalog/suppler.php file an automatic options removal code.

To do this, before the line unset($rows1); insert in this place:

the following code:

$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "relatedoptions WHERE `product_id` = '" . $old_product_id . "'");    
                   
                    if (!empty($query->rows)) {
                        $this->db->query("DELETE FROM " . DB_PREFIX . "product_option_value WHERE product_id = '" . $old_product_id . "'");
                               
                        $this->db->query("DELETE FROM " . DB_PREFIX . "product_option WHERE product_id = '" . $old_product_id . "'");
                    }

Usergio Copyright © 2022