Okay
  Public Ticket #3958290
Adding Custom Taxonomy (Brands) to Dynamic Rules "Assign To" Field
Closed

Comments

  •  1
    Dovydas started the conversation

    Hello,

    We are using the B2BKing plugin alongside the "Perfect Brands for WooCommerce" plugin on our site. We heavily utilize B2BKing's dynamic rules for pricing and visibility adjustments.

    Our Goal: We need to apply specific dynamic rules based on the 'Brand' of a product. These brands are managed using the custom taxonomy created by the "Perfect Brands for WooCommerce" plugin (we believe the taxonomy slug is likely pwb-brand, but can confirm if necessary).

    The Challenge: Currently, within the B2BKing Dynamic Rule configuration, the "Assign To" field allows us to select:

    • Product Category
    • Product Tags (Beta)
    • Specific Products
    • Specific SKUs
    • All Products

    We would like to add the 'Brand' custom taxonomy from the "Perfect Brands" plugin as an option in this "Assign To" list, so we can directly assign rules to all products of a specific brand.

    Specific Questions:

    1. Is it possible to extend the "Assign To" options within B2BKing's dynamic rules to include a custom taxonomy, such as the one used by 'Perfect Brands for WooCommerce'?
    2. If yes, does B2BKing provide specific WordPress action hooks or filters designed for developers to add custom taxonomies (or other conditions) to this "Assign To" list, Could you please provide them?
    3. Is there any documentation or a code example available that demonstrates how to properly use these hooks/filters to register and handle a custom taxonomy within the dynamic rules assignment logic?


    Understanding if this customization is supported and how it can be implemented (specifically regarding the necessary hooks/filters and any intricate insights) is crucial for our development planning and maybe it would help others with the similar goal.

    Thank you for your time and assistance.

  •  2,406
    WebWizards replied

    Hi there,

    It is possible, with a code snippet, to also add support for a custom taxonomy like brand in dynamic rules.

    The snippet to add is:

    add_filter('b2bking_dynamic_rules_taxonomy_option', function($val){
        return 'brand';
    }, 10, 1);
    add_filter('b2bking_custom_taxonomy_backend_name', function($name){
        return 'Brand Name';
    }, 10, 1);

    Here it sets it to a 'brand' taxonomy instead (assuming that's the slug of the taxonomy and not something else).

    That should result in brands becoming available for selection in rules:

    8848721643.png

     

    Kind regards,

    Stefan