• Hi,

    I am trying to show 2 of my attributes in the archive shop loop.
    I kind of found where I want to put it, but I am wondering wether it is possible to add it within one of the classes/lists, for example the price class, so that I can change the font size.

    In the screenshot you can see how the attributes have a bigger font size (the size of the body): https://prnt.sc/rfs1ya

    This is the code I am using:

    add_action('ocean_after_archive_product_inner', 'display_attributes_after_product_loop_title', 15);
    function display_attributes_after_product_loop_title(){
        global $product;
    
        $output = array(); // Initializing
    
        // The year
        if( $pakket_samenstelling = $product->get_attribute('pa_pakket_samenstelling') ){
            // Save the value in the array
            $output[] = $pakket_samenstelling; 
        }
    
        // The model
        if( $advies_verkoopprijs = $product->get_attribute('pa_advies_verkoopprijs') ){
            // Save the value in the array
            $output[] = $advies_verkoopprijs;
        }
    
        // Output
        if( sizeof($output) > 0 ){
            // Display product attributes coma separated values (you can change the separator by something else below).
            echo implode( ', ', $output);
        }
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Can you please share your site link so that I can check it?

    Thread Starter oberning

    (@oberning)

    Hi,

    Of course: this is the shop page

    Thanks

    Try to use the below code and check it works or not. I have not tested it but it should work.

    if( sizeof($output) > 0 ){
       // Display product attributes comma-separated values (you can change the separator by 
       something else below).
            $productattr = '';
            $productattr = implode( ', ', $output);
            echo '<div class="product-attribute">'. $productattr .'</div>';
       }
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘add_action after price’ is closed to new replies.