PHP code example of orangecat / module-prices

1. Go to this page and download the library: Download orangecat/module-prices library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

orangecat / module-prices example snippets


/**
 * Return the B2B price for a given context, or null if this module
 * has no applicable price.
 */
public function calculate(string $sku, float $qty, int $companyId, float $basePrice = 0.0): ?float;

/**
 * Return all quantity tiers: [['qty' => 5.0, 'price' => 8.50], ...]
 * Sorted ascending by qty. Return [] if no tiers are configured.
 */
public function getTiers(string $sku, int $companyId, float $basePrice = 0.0): array;

$config->isEnabled($storeId = null): bool
$config->isTierPricesEnabled($storeId = null): bool      // false if engine disabled
$config->getResolutionMode($storeId = null): string      // 'lowest_price' | 'priority'

// Returns the resolved B2B price, or null if no calculator applies.
$resolver->resolve(string $sku, float $qty, int $companyId, float $basePrice): ?float

// Returns merged, resolution-mode-applied tiers sorted ascending by qty.
$resolver->resolveTiers(string $sku, int $companyId, float $basePrice): array