Advanced Dynamic Pricing For WooCommerce

Don’t apply rules during woocommerce product export

The Advanced Dynamic Pricing for WooCommerce plugin automatically applies your discount rules to product prices throughout the store – on product pages, in the catalogue, during cart calculations, and even in the admin area. This behaviour is usually beneficial. However, when you export products using the built‑in WooCommerce export tool (Products → All Products → Export), you typically want the raw, undiscounted prices. Otherwise, your exported price list will show discounted amounts, which may not reflect your actual catalogue values and can cause confusion for accounting, inventory management, or supplier reporting.

This guide provides a simple PHP snippet that temporarily disables all pricing rules during the WooCommerce product export process, ensuring that your exported CSV file contains the original product prices.


The Complete Code Snippet

What the code does:

ElementDescription
add_filter()Registers a callback on a WooCommerce filter hook.
'woocommerce_product_export_row_data'The hook that fires for every row during WooCommerce’s built-in CSV export. It passes the assembled row data array and the WC_Product object.
$rowAn associative array of all column values that will be written to the export file for this product.
$productThe WC_Product object for the current row, providing access to all product methods.
isset( $row['sale_price'] )Guards against products that have no sale price column (e.g. variable parents), preventing unnecessary processing.
$product->get_sale_price( 'edit' )Fetches the sale price directly from the database in edit context, bypassing all filter hooks — including those applied by Advanced Dynamic Pricing. This is the raw, unmodified value.
10, 2Hook priority 10 (standard); 2 indicates the callback accepts two arguments ($row and $product).

The end result: when you run a product export, the Advanced Dynamic Pricing rules are completely ignored, and your exported CSV contains the original product prices from the database.


2. Step‑by‑Step Implementation

Step 1: Choose where to add the code

You have two safe options for adding custom PHP code:

  • Option A (Recommended): Use the free Code Snippets plugin.
    Install the plugin from Plugins → Add New by searching for “Code Snippets”. This is the safest method because it allows you to add, activate, and deactivate snippets without ever editing your theme files.
  • Option B: Add to your child theme’s functions.php file.
    If you are comfortable editing theme files, add the code to your active child theme’s functions.php file. Never add custom code directly to a parent theme, because it will be lost when the theme is updated.

Step 2: Insert the snippet

  • If using Code Snippets:
  • If editing functions.php:

Step 3: Test the functionality

  1. Go to Products → All Products in your WordPress admin area.
  2. Click the Export button at the top of the page.
  3. Choose the export columns you need and click Generate CSV.
  4. Open the downloaded CSV file.
  5. Verify that the prices in the export match the original product prices (without any dynamic discounts applied).

If the exported prices are correct (i.e., no discounts are applied), the implementation is successful.

Have questions? Please submit a support request. We're always happy to help!

Advanced Dynamic Pricing
for WooCommerce
PRO

From $60
Buy
✓ 30-day money-back guarantee