root / drupal7 / sites / all / modules / commerce / modules / product_pricing / commerce_product_pricing.api.php @ 13755f8d
1 |
<?php
|
---|---|
2 |
|
3 |
/**
|
4 |
* @file
|
5 |
* Hooks provided by the Product Pricing module.
|
6 |
*/
|
7 |
|
8 |
|
9 |
/**
|
10 |
* Lets modules invalidate a particular product during the sell price pre-
|
11 |
* calculation process.
|
12 |
*
|
13 |
* Because the price table can very quickly accumulate millions of rows on
|
14 |
* complex websites, it is advantageous to prevent any unnecessary products from
|
15 |
* cluttering up the table. This hook allows modules to prevent pre-calculation
|
16 |
* on an individual product, which is especially useful when it is known that
|
17 |
* products meeting certain criteria will never be featured in Views and other
|
18 |
* displays where it might be sorted or filtered based on a calculated price.
|
19 |
*
|
20 |
* @param $product
|
21 |
* The product being considered for sell price pre-calculation.
|
22 |
*
|
23 |
* @return
|
24 |
* TRUE or FALSE indicating whether or not the product is valid.
|
25 |
*
|
26 |
* @see hook_commerce_product_valid_pre_calculation_rule()
|
27 |
*/
|
28 |
function hook_commerce_product_valid_pre_calculation_product($product) { |
29 |
// Disable sell price pre-calculation for inactive products.
|
30 |
if (!$product->status) { |
31 |
return FALSE; |
32 |
} |
33 |
} |
34 |
|
35 |
/**
|
36 |
* Lets modules invalidate a particular rule configuration during the sell price
|
37 |
* pre-calculation process.
|
38 |
*
|
39 |
* Because the price table can very quickly accumulate millions of rows on
|
40 |
* complex websites, it is advantageous to prevent any unnecessary rule
|
41 |
* configurations from the pre-calculation process. Each additional rule
|
42 |
* configuration exponentially increases the amount of rows necessary for each
|
43 |
* product whose sell price is pre-calculated.
|
44 |
*
|
45 |
* This hook allows modules to prevent pre-calculation for individual rule
|
46 |
* configurations, which is especially useful when it is known that certain
|
47 |
* rule configurations will never affect the prices of products featured in
|
48 |
* Views or other displays that sort or filter based on a calculated price.
|
49 |
*
|
50 |
* @param $rule
|
51 |
* A rule configuration belonging to the commerce_product_calculate_sell_price
|
52 |
* event.
|
53 |
*
|
54 |
* @return
|
55 |
* TRUE or FALSE indicating whether or not the rule configuration is valid.
|
56 |
*
|
57 |
* @see hook_commerce_product_valid_pre_calculation_product()
|
58 |
*/
|
59 |
function hook_commerce_product_valid_pre_calculation_rule($rule) { |
60 |
// TODO: Use the implementation specced in http://drupal.org/node/1020976 as
|
61 |
// an example here.
|
62 |
} |
63 |
|
64 |
/**
|
65 |
* Allows modules to alter the product line item used for sell price calculation.
|
66 |
*
|
67 |
* @param $line_item
|
68 |
* The product line item used for sell price calculation.
|
69 |
*/
|
70 |
function hook_commerce_product_calculate_sell_price_line_item_alter($line_item) { |
71 |
global $user; |
72 |
|
73 |
// Reference the current shopping cart order in the line item if it isn't set.
|
74 |
if (empty($line_item->order_id)) { |
75 |
$line_item->order_id = commerce_cart_order_id($user->uid); |
76 |
} |
77 |
} |