• Resolved Chris

    (@eaonflux)


    Your Greenshiftwoo plugin does not support custom product attributes.

    We have our own plugin that adds 2 custom product attributes but the method “init_term_hooks” in the “GSPBWOO_Attribute_Swatches” class grabs every attributes type it finds and thats not good.

    error: “call_user_func_array(): Argument #1 ($callback) must be a valid callback, class GSPBWOO_Attribute_Swatches does not have a method “add_grid_field””

    We know what the problem is so please constrain only to your own attribute types within your code so your plugin is compatible with other plugins that are adding product attributes

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Chris

    (@eaonflux)

    A dirty fix is that we extend our own class with yours and then we override all methods that are throwing errors but thats not how we want to procede. please fix this ??

    Thread Starter Chris

    (@eaonflux)

    /* Initialization attribute term hooks */
    
    public function init_term_hooks()
    
    {
    
    $swatch_options = get_option( $this->option_name, array() );
    
    $allowed = array(
    
    'select',
    
    'color' ,
    
    'image' ,
    
    'text' ,
    
    'image_tag'
    
    );
    
    $swatch_options = array_intersect($swatch_options, $allowed);
    
    .... your code ....
    
    }
    Plugin Author wpsoul

    (@wpsoul)

    Currently I don’t know what you are doing and how to replicate, but your code looks safe to be added in core

    Thread Starter Chris

    (@eaonflux)

    We are looking to add two additional attribute types – ‘grid’ and ‘slider’ – to be utilized as product page variations. For instance, if we were to link an attribute to the ‘slider’ type in the backend, the product page would then display a slider in place of a dropdown or one of your default types (select, text tag, image tag, color, etc.).

    However, the issue lies in the ‘GSPBWOO_Attribute_Swatches’ class, where the ‘init_term_hooks’ method is designed to dynamically search for methods based on the discovered types, including the ones we introduced through our own plugin. As it stands, it seeks non-existent methods such as ‘add_slider_field’, ‘edit_slider_field’, ‘add_grid_field’, and ‘edit_grid_field’ within your class.

    Moreover, the ‘gspbwoo_wc_dropdown_variation_attribute_options’ function in the ‘helper-functions.php’ file seems to be causing difficulties as well. As a temporary solution, we have chosen to unhook it and modify your function to allow our attribute types to coexist with your default types. As a result, our ‘slider’ and ‘grid’ options will be correctly displayed on the product page, when applicable.

    i hope this makes sense, i am trying to explain it in my best english

    Thread Starter Chris

    (@eaonflux)

    The ‘gspbwoo_wc_dropdown_variation_attribute_options’ function is outputting the frontend content, which complicates our addition of the ‘slider’ and ‘grid’ attributes. This approach results in the generation of extraneous code and JavaScript, which could potentially cause unnecessary bloat in WooCommerce. This is the reason we unhooked your ‘gspbwoo_wc_dropdown_variation_attribute_options’ function and replaced it with our own combined solution.

    However, a more effective approach might be if your ‘gspbwoo_wc_dropdown_variation_attribute_options’ function was built to be extendable. This would allow us, and potentially other developers, to add custom attributes without needing to overwrite the entire function, thereby preventing the output of unnecessary code and ensuring a more streamlined operation.

    Plugin Author wpsoul

    (@wpsoul)

    It’s changed to affect only own types, thank you for notice

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Not compatible with other custom attributes’ is closed to new replies.