| 1 |
<?php |
| 2 |
|
| 3 |
if (!function_exists('hurryt_wc_stock_statuses')) { |
| 4 |
function hurryt_wc_stock_statuses() |
| 5 |
{ |
| 6 |
return [ |
| 7 |
[ |
| 8 |
'name' => __('In stock', 'hurrytimer'), |
| 9 |
'id' => \Hurrytimer\C::WC_IN_STOCK, |
| 10 |
], |
| 11 |
[ |
| 12 |
'name' => __('Out of stock', 'hurrytimer'), |
| 13 |
'id' => \Hurrytimer\C::WC_OUT_OF_STOCK, |
| 14 |
], |
| 15 |
[ |
| 16 |
'name' => __('On backorder', 'hurrytimer'), |
| 17 |
'id' => \Hurrytimer\C::WC_ON_BACKORDER, |
| 18 |
], |
| 19 |
]; |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
if (!function_exists('hurryt_wc_conditions')) { |
| 24 |
function hurryt_wc_conditions() |
| 25 |
{ |
| 26 |
return (new \Hurrytimer\ConditionalLogic())->addRule([ |
| 27 |
'key' => 'stock_status', |
| 28 |
'name' => __('Stock status', 'hurrytimer'), |
| 29 |
'operators' => ['==', '!='], |
| 30 |
'values' => hurryt_wc_stock_statuses(), |
| 31 |
'type' => 'string', |
| 32 |
])->addRule([ |
| 33 |
'key' => 'stock_quantity', |
| 34 |
'name' => __('Stock quantity', 'hurrytimer'), |
| 35 |
'operators' => ['==', '!=', '<', '>'], |
| 36 |
'values' => [], |
| 37 |
'type' => 'number', |
| 38 |
])->addRule([ |
| 39 |
'key' => 'shipping_class', |
| 40 |
'name' => __('Shipping class', 'hurrytimer'), |
| 41 |
'operators' => ['==', '!='], |
| 42 |
'values' => array_map(function ($class) { |
| 43 |
return [ |
| 44 |
'name' => $class->name, |
| 45 |
'id' => $class->term_id, |
| 46 |
]; |
| 47 |
}, \WC_Shipping::instance()->get_shipping_classes()), |
| 48 |
])->get(); |
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
|