Friday, July 29, 2022
HomeWordPress Developmentfilters - woocommerce_variation_option_name hook would not work

filters – woocommerce_variation_option_name hook would not work


I’ve following code inserted into capabilities.php:

add_filter( 'woocommerce_variation_option_name','display_price_in_variation_option_name');

operate display_price_in_variation_option_name( $time period ) {
    world $product;

    if ( empty( $time period ) ) {
        return $time period;
    }
    if ($product == null) {
        return $time period;
    }

    $variation_id = $product->get_children();

    foreach ( $variation_id as $id ) {
        $_product       = new WC_Product_Variation( $id );
        $variation_data = $_product->get_variation_attributes();

        foreach ( $variation_data as $key => $knowledge ) {
            if ( $knowledge == $time period ) {
                $html = $time period;
                $html .= $_product->get_stock_quantity() > 0 ? ' - Quick Supply' : '';
                return $html;
            }
        }
    }

    return $time period;
}

It has to show ‘Quick supply’ possibility proper subsequent to the scale if the scale in inventory proper now.

Perhaps there is a matter in the way in which I add attributes to the product, as a result of this code works earlier than. Beforehand I added attributes like this:
enter image description here

Then I made a decision to make this attribute world so my search filter works properly. And now I merely select Dimension attribute as a substitute of Create customized attribute possibility.

So my attribute seems to be like this:
enter image description here

And this:

enter image description here

Do you could have some concepts how one can make this code alive?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments