• Resolved pablorsa

    (@pablorsa)


    WP 6.0
    WVS 2.0.1

    Warning: Trying to access array offset on value of type bool in D:\Website\wordpress\wp-content\plugins\woo-variation-swatches\includes\class-woo-variation-swatches-product-page.php on line 442

    I have an attributes as type “image” but I did not include any image in the attribute terms. (I thought that the plugin would get the variation image not the image of the attribute.)

    This needs to either display the placeholder image on failure or maybe a fallback actions to change the $attribute_type from “image” to “button”.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support fizanzvai

    (@fizanzvai)

    @pablorsa

    It’s a warning. It will not show if you turn off error reporting. We’ll try to add a fallback in the coming version.

    Thank You

    Thread Starter pablorsa

    (@pablorsa)

    I can confirm this error had been fixed.

    I did some code to do what I wanted and that is to place the product image on the swatch image, however the update messed that up as there is no more IMG tag with the fallback 🙁
    I have since changed code to correct it and hopefully works for future updates. If anyone wanted it. (Still learning WP)
    This also uses a custom field in variations called title which can be found ” https://www.businessbloomer.com/woocommerce-add-custom-field-product-variation/

    
    add_action( 'woocommerce_after_variations_form', 'wvs_modifications', 20 );
    function wvs_modifications() {
      if ( class_exists( 'Woo_Variation_Swatches', false ) ) {
        if ( is_product()){
          
        ?>
        <script>
        /* WVS Title and Image Hack */
        jQuery(document).ready(function($) {
          $(".variations_form .image-variable-items-wrapper").each(function(e) {
            var jArray = $('.variations_form').data('product_variations');
            for (var obj = 0; obj < jArray.length; obj++) {
              var variation = jArray[obj]['attributes'][$(this).data('attribute_name')];
              if ($('[data-value="' + variation + '"]')) {
                var title = (jArray[obj]['title']) ? jArray[obj]['title']  : '' ;
                $('.variations_form li[data-value="' + variation + '"]').find('div').html('<img src="' + jArray[obj]['image']['gallery_thumbnail_src'] + '" alt="' + title + '" title="' + title + '" width="50" height="50">'); 
                if (title.length > 0) {
                  $('.variations_form li[data-value="' + variation + '"]').attr('data-title', title).attr('data-wvstooltip', title);
                }
              }
            }
          });
        });
        </script>
        <?php
        }
      }
      return false;
    }
    
    • This reply was modified 3 years, 9 months ago by pablorsa.
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Attribute type “Image” error when no image used.’ is closed to new replies.