Pricing Engine

Advanced pricing system with price lists, validity periods, and polymorphism.

Pricing Engine

Obelaw PIM features a powerful pricing system designed for both B2B and B2C scenarios. It handles complex logic like promotional periods and variant specific pricing overrides.

Key Features

FeatureDescription
Price ListsCreate unlimited lists (e.g., “Wholesale 2026”, “Black Friday”).
Validity PeriodsEnforce strict start_date and end_date on price lists.
PolymorphismAssign specific prices to a parent Product OR override them at the Variant level.
Special PricesBuilt-in support for promotional pricing with precedence logic.

Managing Price Lists

You can create scoped price lists for specific channels, customers, or seasons.

use Obelaw\Pim\Models\PriceList;

$summerSale = PriceList::create([
    'name' => 'Summer Sale 2026',
    'currency_code' => 'USD',
    'start_date' => '2026-06-01',
    'end_date' => '2026-08-31',
    'is_active' => true
]);

Assigning Prices

Assign a standard price and an optional special price to a product for a specific price list.

// Assign promotional price to a product
$product->prices()->create([
    'price_list_id' => $summerSale->id,
    'price' => 100.00,
    'special_price' => 89.99 // Automatic precedence during valid dates
]);

Price Resolution

The PIM facade provides a resolver helper that automatically determines the best effective price for a given context. The resolver checks:

  1. Is the price list active?
  2. Is today within the start_date and end_date?
  3. Does the variant have a specific override price? If not, does the parent product have a price?
  4. Is there a valid special_price?
use Obelaw\Pim\Facades\PIM;

$resolver = PIM::prices();

// PIM automatically checks validity dates and Variant overrides
$finalPrice = $resolver->resolve($variant, $currentPriceListId);