简体   繁体   中英

Woocommerce: Add Price Suffix incl. Hyperlink

is it possible to add a Hyperlink to the Price Suffix of WooCommerce?

To add a Suffix, I used this Code

add_filter( 'woocommerce_get_price_html', 'custom_price_suffix', 100, 2 );

function custom_price_suffix( $price, $product ){
        $price = $price . 'zzgl. Versandkosten' ;
            return apply_filters( 'woocommerce_get_price', $price );
}

To Show the Text "zzgl. Versandkosten". I want to add a Hyperlink to "zzgl. Versandkosten" where Customers can read a PDF Documentation about our Shipping prices.

Thanks

Mauro

Simply add an anchor tag to the appended text like so:

add_filter( 'woocommerce_get_price_html', 'custom_price_suffix', 100, 2 );

function custom_price_suffix( $price, $product ){
    $price = $price . '<a href="/">zzgl. Versandkosten</a>';
    return apply_filters( 'woocommerce_get_price', $price );
}

You can replace the '/' in the a tag with the URL you want to go to.

Can you try this?

    add_filter( 'woocommerce_get_price_html', 'custom_price_suffix', 100, 2 );

function custom_price_suffix( $price, $product ){
        $price = '<a href="link">' . $price . 'zzgl. Versandkosten </a>' ;
            return apply_filters( 'woocommerce_get_price', $price );
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM