GET FREE VERSION GET THE PRO VERSION

Documentation

Here you can find description of main plugin features and some how-to solutions.

Hooks Reference

HookTypeDescription
awl_labels_outputfilterLabels container HTML markup for each WooCommerce product
awl_show_label_for_productfilterShow or not label on current product
awl_show_labels_for_productfilterShow or not all available labels for the current product.
awl_label_markupfilterLabels HTML markup for each WooCommerce product
awl_label_container_stylesfilterFilter labels container styles
awl_label_wrapper_stylesfilterFilter label wrapper styles
awl_label_stylesfilterFilter label block styles
awl_label_text_stylesfilterFilter label inner styles
awl_labels_text_varsfilterFilter label text variables
awl_labels_hooksfilterFilter label hooks that used to display labels
awl_js_selectorsfilterFilter js selectors for labels
awl_get_labelsfilterGet and filter all available labels IDs
awl_svg_iconsfilterFilter label svg icons
awl_label_rulesfilterAdmin hook. Filter label condition rules option
awl_labels_positionsfilterAdmin hook. Display labels positions options
awl_woocommerce_hooksfilterAdmin hook. Filter standard WooCommerce hooks

 

awl_labels_output

apply_filters( 'awl_labels_output', (string) $label_html, (string) $label_position_type );

Labels container HTML markup for each WooCommerce product. Container can have several labels inside.

Changelog

  • Added in version 1.00

Parameters

  • $label_html ( string) Labels HTML markup for current product
  • $label_position_type ( string) Labels position for current product

Example

Lets wrap labels output with .labels-wrapper div block.

add_filter( 'awl_labels_output', 'my_awl_labels_output', 10, 2 );
function my_awl_labels_output( $label_html, $label_position_type ) {
    $label_html = '<div class="labels-wrapper">' . $label_html . '</div>';
    return $label_html;
}

 

awl_show_label_for_product

apply_filters( 'awl_show_label_for_product', (bool) $show, (object) $product, (int) $label_id );

Show or not label for current product.

Changelog

  • Added in version 1.07

Parameters

  • $show (bool) Show or not label.
  • $product (object) WooCommerce product object.
  • $label_id (int) Label ID.

Example

Lets add the following rule: Hide for product with ID 123 lables with IDs 5, 7 and 8.

add_filter( 'awl_show_label_for_product', 'my_awl_show_label_for_product', 10, 3 );
function my_awl_show_label_for_product( $show, $product, $label_id ) {
    $labels_to_exclude = array( 5, 7, 8 );
    if ( $product->get_id() === 123 && in_array( $label_id, $labels_to_exclude )  ) {
        return false;
    }
    return $show;
}

 

awl_show_labels_for_product

apply_filters( 'awl_show_labels_for_product', (bool) $disable_labels, (object) $product );

Show or not all available labels for the current product.

Changelog

  • Added in version 1.07

Parameters

  • $disable_labels (bool) Show or not the labels.
  • $product (object) WooCommerce product object.

Example

Hide all labels for products with IDs 1, 2 and 3.

add_filter( 'awl_show_labels_for_product', 'my_awl_show_labels_for_product', 10, 2 );
function my_awl_show_labels_for_product( $disable_labels, $product ) {
    $hide_for_products = array( 1, 2, 3 );
    if ( in_array( $product->get_id(), $hide_for_products ) ) {
        return true;
    }
    return $disable_labels;
}

 

awl_label_markup

apply_filters( 'awl_label_markup', (string) $html, (string) $position_type, (array) $labels );

Labels HTML markup for each WooCommerce product.

Changelog

  • Added in version 1.00

Parameters

  • $html ( string) Labels HTML markup for current product
  • $position_type ( string) Labels position for current product
  • $labels ( array) Array of labels inside this html markup for current position

Example

Lets wrap labels output with .labels-wrapper div block.

add_filter( 'awl_label_markup', 'my_awl_label_markup', 10, 3 );
function my_awl_label_markup( $html, $position_type, $labels ) {
    $html = '<div class="labels-wrapper">' . $html . '</div>';
    return $html;
}

 

awl_label_container_styles

apply_filters( 'awl_label_container_styles', (array) $styles, (string) $position_type, (array) $labels );

Filter labels container styles before output. Containers can have one or more labels inside.

Changelog

  • Added in version 1.00

Parameters

  • $styles (array) Array of container styles for current product
  • $position_type (string) Labels position for current product
  • $labels (array) Array of labels inside this container for current position

Example

Change container position style to relative if position type is on_image.

add_filter( 'awl_label_container_styles', 'my_awl_label_container_styles', 10, 3 );
function my_awl_label_container_styles( $styles, $position_type, $labels ) {
    if ( $position_type === 'on_image' ) {
        $styles['position'] = 'relative';
        $styles['z-index'] = '0';
    }
    return $styles;
}

 

awl_label_wrapper_styles

apply_filters( 'awl_label_wrapper_styles', (array) $styles, (string) $position_type, (array) $settings );

Filter label wrapper styles before output.

Changelog

  • Added in version 1.00

Parameters

  • $styles (array) Array of wrapper styles for current product
  • $position_type (string) Label position for current product
  • $settings (array) Array of label settings

Example

Add new style margin: 10px for labels wrapper.

add_filter( 'awl_label_wrapper_styles', 'my_awl_label_wrapper_styles', 10, 3 );
function my_awl_label_wrapper_styles( $styles, $position_type, $settings ) {
    $styles['margin'] = '10px';
    return $styles;
}

 

awl_label_styles

apply_filters( 'awl_label_styles', (array) $styles, (string) $position_type, (array) $settings );

Filter label block styles before output. Overwrites label settings that were specified from the label edit page.

Changelog

  • Added in version 1.00

Parameters

  • $styles (array) Array of styles for current product
  • $position_type (string) Label position for current product
  • $settings (array) Array of label settings

Example

Change font color and size for all labels.

add_filter( 'awl_label_styles', 'my_awl_label_styles', 10, 3 );
function my_awl_label_styles( $styles, $position_type, $settings ) {
    $styles['color'] = '#000';
    $styles['font-size'] = '12px';
    return $styles;
}

 

awl_label_text_styles

apply_filters( 'awl_label_text_styles', (array) $styles, (string) $position_type, (array) $settings );

Filter label inner styles before output. Overwrites label settings that were specified from the label edit page.

Changelog

  • Added in version 1.00

Parameters

  • $styles (array) Array of inner styles for current product
  • $position_type (string) Label position for current product
  • $settings (array) Array of label settings

Example

Change label background color for Shop page only.

add_filter( 'awl_label_text_styles', 'my_awl_label_text_styles', 10, 3 );
function my_awl_label_text_styles( $styles, $position_type, $settings ) {
    if ( is_shop() ) {
        $styles['background'] = '#ff0000';
    }
    return $styles;
}

 

awl_labels_text_vars

apply_filters( 'awl_labels_text_vars', (array) $variables );

Filter label text variables.

Changelog

  • Added in version 1.00

Parameters

  • $variables ( array ) Array of text variables

Example

Lets add a new text variable {DOUBLE_PRICE} that will show product price multiplied by 2.

add_filter( 'awl_labels_text_vars', 'my_awl_labels_text_vars' );
function my_awl_labels_text_vars( $variables ) {
    $variables['/{DOUBLE_PRICE}/i'] = array( 'func' => 'awl_double_price_show' );
    return $variables;
}

function awl_double_price_show() {
    global $product;
    $price = $product->get_price() * 2;
    return $price;
}

 

awl_labels_hooks

apply_filters( 'awl_labels_hooks', (array) $hooks );

Filter label hooks that used to display labels.

Changelog

  • Added in version 1.00

Parameters

  • $hooks ( array ) Array of WooCommerce hooks

Example

Default plugin hooks work fine with almost all WordPress themes but sometimes it is still necessary to change some default hooks to display labels. Let's change the hook that used to display labels on shop/archive pages for on_image position.

add_filter( 'awl_labels_hooks', 'my_awl_labels_hooks' );
function my_awl_labels_hooks( $hooks ) {
    $hooks['on_image']['archive'] = array( 'woocommerce_before_shop_loop_item' => array( 'priority' => 10 ) );
    return $hooks;
}

 

awl_js_selectors

apply_filters( 'awl_js_selectors', (array) $selectors );

Filter js selectors for labels. JS selectors can be used when it is not possible to display labels with standard php hooks. For example, when a certain theme just doesn't support any of the product hooks.

Changelog

  • Added in version 1.00

Parameters

  • $selectors ( array ) Array of css selectors

Example

Lets display labels via JS for products archive pages. To use js hook only for achive pages we will use selector .awl-label-type-archive. Second argument - array that specify where to add these labels relative to product blocks. For example, in our theme we have block .et_shop_image and want to append labels inside it.
It is possible to use append, prepend, before and after to describe how labels must be added relative to the selected box.

add_filter( 'awl_js_selectors', 'my_awl_js_selectors' );
function my_awl_js_selectors( $selectors ) {
    $selectors['.awl-label-type-archive'] = array( '.et_shop_image', 'append' );
    return $selectors;
}

 

awl_get_labels

apply_filters( 'awl_get_labels', (array) $labels );

Filter all published labels IDs. Used each time when labels displayed on the pages.

Changelog

  • Added in version 1.00

Parameters

  • $labels ( array ) Array of labels IDs

Example

We can, for example, remove label with ID 8158 from the Shop page.

add_filter( 'awl_get_labels', 'my_awl_get_labels' );
function my_awl_get_labels( $labels ) {
    if ( is_shop() ) {
        $label_key = array_search( '8158', $labels );
        unset( $labels[$label_key] );
    }
    return $labels;
}

 

awl_svg_icons

apply_filters( 'awl_svg_icons', (array) $icons );

Filter labels svg icons that are used for labels shapes.

Changelog

  • Added in version 1.00

Parameters

  • $icons (array) Array of available svg icons

Example

Change svg for one of the icons.

add_filter( 'awl_svg_icons', 'my_awl_svg_icons' );
function my_awl_svg_icons( $icons ) {
    $icons['angle-after'] = '<g class="awl-triangled-after"><polygon vector-effect="non-scaling-stroke" points="0,0 0,100 97,50" style="stroke:none;" /><line vector-effect="non-scaling-stroke" x1="0" y1="0" x2="97" y2="50" /><line vector-effect="non-scaling-stroke" x1="97" y1="50" x2="0" y2="100" /></g>';
    return $icons;
}

 

awl_label_rules

apply_filters( 'awl_label_rules', (array) $rules );

Admin hook. Filter label condition rules option. Only for the admin area.

Changelog

  • Added in version 1.00

Parameters

  • $rules ( array ) Array of label rules

Example

Add a new rule called Some custom value inside the label edit page.

add_filter( 'awl_label_rules', 'my_awl_label_rules' );
function my_awl_label_rules( $rules ) {
    $rules['attributes'][] = array(
        "name" => __( "Some custom value", "advanced-woo-labels" ),
        "id"   => "custom_value",
        "type" => "number",
        "operators" => "equals_compare",
    );
    return $rules;
}

 

awl_labels_positions

apply_filters( 'awl_labels_positions', (array) $positions );

Admin area hook. Filter available labels positions before displaying inside label hooks table for settings page.

Changelog

  • Added in version 1.00

Parameters

  • $positions ( array ) Array of available labels positions

Example

Create new labels position after_title and display it for label settings page.

add_filter( 'awl_labels_positions', 'my_awl_labels_positions' );
function my_awl_labels_positions( $positions ) {
    $positions[] = array( 'slug' => 'after_title', 'name' => __( 'After title', 'advanced-woo-labels' ) );
    return $positions;
}

 

awl_woocommerce_hooks

apply_filters( 'awl_woocommerce_hooks', (array) $hooks );

Admin area hook. Filter standard WooCommerce hooks that are used for hooks table inside the plugin settings page.

Changelog

  • Added in version 1.00

Parameters

  • $hooks ( array ) Array of available WooCommerce hooks

Example

Remove woocommerce_before_shop_loop_item hook from the list of default WooCommerce hooks.

add_filter( 'awl_woocommerce_hooks', 'my_awl_woocommerce_hooks' );
function my_awl_woocommerce_hooks( $hooks ) {
    $hook_key = array_search( 'woocommerce_before_shop_loop_item', $hooks );
    unset( $hooks[$hook_key] );
    return $hooks;
}