This plugin (formerly named Attribute Image Swatch) adds a new Option Type to your Zen Cart — Image Swatch. That option type swaps a product's main-image display with an attribute-specific image upon click. Multiple product quantities can be entered, one for each configured "option value". See it in action here.
An Image Swatch type attribute displays each option-value as a block showing the attribute's "small" color swatch, its name and price and a quantity dropdown. If the Products' Options' Stock Manager is installed, the display can optionally include the option-value-specific stock level.
Each Quantity dropdown ranges from 0 to ATTR_SWATCH_MAX_QUANTITY, in increments of the product-specific Product Quantity Units. A customer can choose various quantities of each option value and then click the add-to-cart button. When a product's configuration includes an Image Swatch option, the quantity input in the add-to-cart block is disabled.
The bottom-left image shows the change in the product's information display after clicking the image associated with the Green option. If the customer subsequently clicks the "larger image" link, the large image associated with the attribute's image-swatch is displayed.
This section identifies the processes you'll use to initially install, upgrade, or uninstall AIS entirely.
The first time an admin signs into (or refreshes the screen of) your Zen Cart admin after you have installed the files for Attribute Image Swapper, an initialization script runs that creates the Image Swatch option type within your products_options_types database table.
Now, when you you define a new option name using Catalog->Option Name Manager, one of the selections is Image Swatch. Use that option-type to enable the Image Swatch functionality for your store's products.
Select the Image Swatch option type when defining your new option within Catalog->Option Name Manager.
Define the option values for your new option using Catalog->Option Value Manager.
Use Catalog->Attributes Controller to associate your new option with a product. For the Image Swatch type attribute, it's important to to associate an Attributes Image Swatch image to each of the option's values — that setting is towards the bottom of the Attributes Controller's display.
If your store doesn't use Image Handler5, make sure that you have also uploaded a medium and large image for each of your attributes' swatches! The large image will be used on the product's detailed information page (e.g. product_info), displayed by either the Fuel Slimbox or Zen Colorbox plugin (if enabled), the Bootstrap-4 template's modal display or a pop-up window otherwise.
Note: Make sure that Configuration :: Attributes :: Enable Attributes Images is set to true; its default is false. Without that setting, you won't be able to add images to your attributes!
The store-side processing for Attribute Image Swapper makes use of the following built-in Zen Cart configuration elements:
Within a product's configuration (Catalog->Categories/Products), the value set for Product Quantity Units defines the increment used for an image-swatch quantity drop-down menu and the value set for Product Quantity Maximum is enforced when image-swatch items are added to the customer's cart.
An attribute's swatch image is displayed using the values specified in Configuration->Images->Small Image Width and ->Small Image Height.
The setting in Configuration->My Store->Display Cart After Adding Product is used after a successful add-to-cart action of an AIS-enabled product.
The setting in Configuration->Stock->Allow Checkout is used during the add-to-cart action. If the value is set to false, then at most the stock-on-hand can be added to the cart.
If your store has installed:
Image Handler5 for Zen Cart 1.5.5+, then the image-swatch processing will use IH5 to process any attribute images — enabling you to upload only the attribute's large image.
Fuel Slimbox (Lightbox) or ColorBox for Zen Cart, then the large-image display resulting from an image-swatch replacement will display the selected attribute's "large" image — otherwise, the built-in Zen Cart pop-up window is used.
Bootstrap-4 Template, then AIS "plays nice" with that template's modal product-image display.
Note:Attribute Image Swapper "plays well" with all other option types except the File option type. If a product's attributes include both Image Stock and File option types, the file-related input is ignored when the product is added to the cart.
There are two configuration switches, currently available by editing /includes/classes/observers/class.attribute_swatch_observer.php:
ATTR_SWATCH_MAX_QUANTITY — the value entered here (default: 16) is the largest value displayed in each option-value's Quantity dropdown menu.
ATTR_SWATCH_SHOW_STOCK_QUANTITY — this value, either 'true' (default) or 'false' — indicates whether or not to display the option-value-specific stock quantity on the products' details pages. Requires prior installation of the Products' Options' Stock Manager.
Starting with AIS v2.1.0, there's also a configuration setting in Configuration :: Attribute Settings: Attribute Image Swapper: Use Minimized Script?. That value defaults to Yes and, unless you're trying to debug the plugin's jQuery processing, doesn't need to be changed.
This section identifies the plugin's version-history and files changed in each version.
v2.2.0, 2023-02-08:
CHANGE: Minimum Zen Cart version supported is now 1.5.7a.
CHANGE: Refactoring for current PHP versions; declaring all class variables for PHP 7.4+.
BUGFIX: Products with an "Image Swatch" option type always require selection.
CHANGE: Moved the AIS jQuery scripts to template_default so they're available for all templates. Be sure to remove the version from your current template if you're upgrading!
BUGFIX: Correct product's "Starting at" price for AIS products priced-by-attribute with additional attribute types.
The following files were changed, added or removed:
CHANGE: Re-insert the configuration items PRODUCTS_OPTIONS_TYPE_SELECT, UPLOAD_PREFIX and TEXT_PREFIX if they're missing due to poorly-coded plugins' SQL installation scripts.
BUGFIX: Incorrect product price calculated when multiple AIS attributes are used on a single product. The price is now calculated as the "base price" plus the minimum value of allAIS attributes.