Helpers

We moved these functions to static class  WDP_Functions  (but legacy class WDP_Frontend can be used too).

adp_functions()->getGiftedCartProducts() just returns array of free items (added by our plugin)  as [product_id_1=>qty_1, product_id_2=>qty_2,..]

adp_functions()->getActiveRulesForProduct($productId, $qty = 1, $useEmptyCart = false) adds passed product to existing cart (or empty cart) and returns array of applied rules.

adp_functions()->calculateProduct($product, $qty, $useEmptyCart = true) allows you to calculate an object \ADP\BaseVersion\Includes\Product\ProcessedProductSimple
or an object \ADP\BaseVersion\Includes\Product\ProcessedVariableProduct.
And in the pro version it calculates an object \ADP\ProVersion\Includes\Product\ProcessedVariableProduct.

adp_functions()->getDiscountedProductsForCart($listOfProducts, $plain = false) allows you to calculate price for list of products. You can use the following parameters:

  1. listOfProducts
    array[][‘product_id’]
    array[][‘qty’]
    array[][‘cart_item_data’] Optional
  2. $plain
    true/false

The function has 2 different return schemas.

It sounds a bit confusing, but you can use this way to get list of products which should be added to pre-build cart to get discounts.

adp_functions()->getDiscountedProductPrice($product, $qty, $useEmptyCart = true) allows you to calculate price for product. You can use the following parameters:

  1. int|WC_product $product(product id or product object)
  2. float $qty
  3. bool $useEmptyCart

The function has 3 different return schemas which are depended on first provided parameter:

float|array|null
float for simple product
array is (min, max) range for variable
null if product is incorrect