| @@ -412,10 +412,15 @@ | ||
| 412 | 412 | if ( ! function_exists( 'disco_apply_category_bogo_paid_ratio' ) ) { |
| 413 | 413 | /** |
| 414 | 414 | * Scale a partly-free cart line's price down to its paid units. |
| 415 | 415 | * |
| 416 | - * Runs after Disco's own product price filters (priority 999), so the free | |
| 417 | - * units are removed from whatever price the other campaigns resolved. | |
| 416 | + * Runs after Disco's own product price filters, so the free units are | |
| 417 | + * removed from whatever price the other campaigns resolved. Those filters | |
| 418 | + * sit at PHP_INT_MAX, so this one shares that priority and relies on | |
| 419 | + * registration order: bogo.php is required after product.php, and WordPress | |
| 420 | + * runs same-priority callbacks in the order they were added. Registering | |
| 421 | + * lower would put this first, and disco_discounted_price would then re-read | |
| 422 | + * the base price and discard the scaling. | |
| 418 | 423 | * |
| 419 | 424 | * @param float|string $price Product price. |
| 420 | 425 | * @param \WC_Product $product Product object. |
| 421 | 426 | * @return float|string |
| @@ -434,10 +439,10 @@ | ||
| 434 | 439 | |
| 435 | 440 | return (float) $price * $ratios[ $object_id ]; |
| 436 | 441 | } |
| 437 | 442 | |
| 438 | - add_filter( 'woocommerce_product_get_price', 'disco_apply_category_bogo_paid_ratio', 1000, 2 ); | |
| 439 | - add_filter( 'woocommerce_product_variation_get_price', 'disco_apply_category_bogo_paid_ratio', 1000, 2 ); | |
| 443 | + add_filter( 'woocommerce_product_get_price', 'disco_apply_category_bogo_paid_ratio', PHP_INT_MAX, 2 ); | |
| 444 | + add_filter( 'woocommerce_product_variation_get_price', 'disco_apply_category_bogo_paid_ratio', PHP_INT_MAX, 2 ); | |
| 440 | 445 | } |
| 441 | 446 | |
| 442 | 447 | if ( ! function_exists( 'disco_free_product_label' ) ) { |
| 443 | 448 | /** |