shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php

Show Regular Price Instead of CSP on Archive Pages Only

This article helps you achieve a regular price on the Archive page if you have set a CSP rule.

For better understanding please refer to the screenshot.

Screenshot 1: Archive Page

Screenshot 2: Single Product Page

If this is your requirement, please follow our instructions.

Please add the following code to the functions.php file of the active theme.

Code Snippet:

// Added by Wisdmlabs
add_filter( 'woocommerce_get_price_html', 'my_custom_price_html', 10, 2 );

function my_custom_price_html( $price_html, $product ) {

    global $woocommerce_loop;
    // Check if the product is a simple or variable product
    if ( ($product->is_type( 'simple' ) || $product->is_type( 'variable' )) && (is_archive() || $woocommerce_loop['name'] == 'up-sells') ) {
        // Get the regular price of the product
        $regular_price = $product->get_regular_price();

        // If the regular price is not empty, display it instead of the sale price
        if ( ! empty( $regular_price ) ) {
            $price_html = wc_price( $regular_price );
        }
    }
    return $price_html;
}
Updated on June 16, 2024
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php

Was this article helpful?

shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php

Related Articles