FunctionalityWooCommerce

AI-written WooCommerce code shows the wrong prices

Prices on product pages, in the cart or at checkout do not match, or discounts apply where they should not. AI-written price code often hooks into the wrong place or misses cached prices.

  • Difficulty: Medium
  • Time: 1 to 3 hours
  • Updated October 28, 2026

Symptoms

  • The product page shows one price and the cart another
  • Discounts apply twice or not at all
  • Variable products show the wrong price range
  • Prices are right for you but wrong for customers

Why it happens

WooCommerce calculates and shows prices in several places: the product page, the shop list, the cart and the checkout. Custom code has to change the price in the right place, or the numbers stop matching.

AI-written snippets often change only the displayed price, or only one product type. WooCommerce also stores some price ranges for variable products, so old values can stick around after a code change.

Try this first

  1. Find the code that changes prices

    Search your theme and custom plugins for price-related hooks.

    grep -rn "woocommerce_product_get_price\|woocommerce_get_price_html\|woocommerce_before_calculate_totals" wp-content/themes wp-content/plugins/your-plugin
  2. Check where the price is changed

    Changing woocommerce_get_price_html only changes what people see, not what they pay. Real price changes belong in the price getters or in the cart calculation.

    // Display only. The cart still uses the original price.
    add_filter( 'woocommerce_get_price_html', 'my_price_label', 10, 2 );
    
    // Changes the price used in the cart.
    add_action( 'woocommerce_before_calculate_totals', function ( $cart ) {
        if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
            return;
        }
        foreach ( $cart->get_cart() as $item ) {
            // set the new price with $item['data']->set_price( ... )
        }
    } );
  3. Cover variable products

    Variations use their own hooks, like woocommerce_product_variation_get_price. Code that only handles simple products leaves variations unchanged.

  4. Clear stored prices

    Go to WooCommerce, Status, Tools and clear transients, then clear your site cache. Old variation price ranges are often stored there.

  5. Test as a customer

    In a private window, add products to the cart, apply coupons and go to checkout. Compare every price with what you expect.

When to stop and call a person

Get a developer fast if customers are paying the wrong amount. Price bugs cost money with every order, and fixing them usually means reading all the custom price code together, not one snippet at a time.

Request a repair crew

Questions people ask

Can I use a plugin instead of custom code?

Often yes. Dynamic pricing and discount plugins cover most common rules and are tested by many stores.

Why are prices right for me but not for customers?

Common causes are caching, role-based price code or code that only runs when you are logged in as admin.

Related fixes