Drop-down Attributes Stop Working After Installing AIS

 plugins, troubleshoot, zen-cart  Comments Off on Drop-down Attributes Stop Working After Installing AIS
Mar 152015

If your normal drop-down (a.k.a select-type) attributes stop working after installing my Attribute Image Swatch plugin, then your site’s been the victim of an improperly-coded plugin’s installation SQL script.  This issue has been “known” for a couple of years, with swguy posting this in April of 2012.

I’ll be updating AIS real-soon-now to pro-actively re-insert the missing configuration items if they are not found in your store’s database.  The base Zen Cart install started, as of ZC 1.5.3, creating the problematic configuration items as hidden items within the “Modules” configuration group to circumvent problems in the future.

Update (2015-03-16): Attribute Image Swatch v1.1.4 has been released, including the above change.

Enabling styling of the min/max/units/mix values

 hints, php, v1.5.0, v1.5.1, zen-cart  Comments Off on Enabling styling of the min/max/units/mix values
Feb 062013

Zen Cart provides a lot of flexibility for a shop owner to specify how an individual product is purchased.  One element of this flexibility is the specification of the Minimum Quantity, Units, Maximum Quantity and Minimum Quantity/Units Mix values when a product is created in your Zen Cart’s admin.   It can be a bit frustrating to control the built-in display of these configured values, especially if you’ve taken the time to incorporate text into a product’s description to guide the customer in the buying process.

minmaxThe image to the right illustrates some of the Zen Cart demo products that show off this configuration.  Even in the demo, each product’s description takes the time to explain what the Max, Min, Units and especially *Mixed OFF actually mean.

Styling these values is “challenging” based on the built-in formatting, which provides no individual elements.  For example, the HTML generated for these settings in the “Min and Units NOMIX” product is

Min:  6 Units:  3<br />*Mixed OFF

Hmm, not much room for separate formatting!

Changing this behavior requires, unfortunately, a change to the function zen_get_products_quantity_min_units_display in the Zen Cart core file  /includes/functions/functions_prices.php.  Make a backup copy of that file and then replace that function with the following code:

// Return a products quantity minimum and units display
  function zen_get_products_quantity_min_units_display($product_id, $include_break = true, $shopping_cart_msg = false) {
    $check_min = zen_get_products_quantity_order_min($product_id);
    $check_units = zen_get_products_quantity_order_units($product_id);


    if ($check_min != 1 or $check_units != 1) {
      if ($check_min != 1) {
        $the_min_units .= '<span class="qmin">' . PRODUCTS_QUANTITY_MIN_TEXT_LISTING . '&nbsp;' . $check_min . '</span>';
      if ($check_units != 1) {
        $the_min_units .= '<span class="qunit">' . ($the_min_units ? ' ' : '' ) . PRODUCTS_QUANTITY_UNIT_TEXT_LISTING . '&nbsp;' . $check_units . '</span>';

// don't check for mixed if not attributes
      $chk_mix = zen_get_products_quantity_mixed((int)$product_id);
      if ($chk_mix != 'none') {
	$the_min_units .= '<span class="qmix">';
        if (($check_min > 0 or $check_units > 0)) {
          if ($include_break == true) {
            $the_min_units .= '<br />' . ($shopping_cart_msg == false ? TEXT_PRODUCTS_MIX_OFF : TEXT_PRODUCTS_MIX_OFF_SHOPPING_CART);
          } else {
            $the_min_units .= '&nbsp;&nbsp;' . ($shopping_cart_msg == false ? TEXT_PRODUCTS_MIX_OFF : TEXT_PRODUCTS_MIX_OFF_SHOPPING_CART);
        } else {
          if ($include_break == true) {
            $the_min_units .= '<br />' . ($shopping_cart_msg == false ? TEXT_PRODUCTS_MIX_ON : TEXT_PRODUCTS_MIX_ON_SHOPPING_CART);
          } else {
            $the_min_units .= '&nbsp;&nbsp;' . ($shopping_cart_msg == false ? TEXT_PRODUCTS_MIX_ON : TEXT_PRODUCTS_MIX_ON_SHOPPING_CART);
	$the_min_units .= '</span>';

    // quantity max
    $check_max = zen_get_products_quantity_order_max($product_id);

    if ($check_max != 0) {
      $the_min_units .= '<span class="qmax">';
      if ($include_break == true) {
        $the_min_units .= ($the_min_units != '' ? '<br />' : '') . PRODUCTS_QUANTITY_MAX_TEXT_LISTING . '&nbsp;' . $check_max;
      } else {
        $the_min_units .= ($the_min_units != '' ? '&nbsp;&nbsp;' : '') . PRODUCTS_QUANTITY_MAX_TEXT_LISTING . '&nbsp;' . $check_max;
      $the_min_units .= '</span>';

    return $the_min_units;

Now, the display looks exactly the same, but the generated HTML looks like:

<span class="qmin">Min: &nbsp;6</span><span class="qunit"> Units: &nbsp;3</span><span class="qmix"><br />*Mixed OFF</span>

That’s something that can be styled! If I want, I can “hide” the *Mixed OFF by adding the following to my CSS stylesheet:

.qmix { display: none; }