| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package Disco |
| 4 |
* @subpackage \App\Intents |
| 5 |
*/ |
| 6 |
|
| 7 |
namespace Disco\App\Intents; |
| 8 |
|
| 9 |
/** |
| 10 |
* Class Cart |
| 11 |
* |
| 12 |
* @package Disco |
| 13 |
* @subpackage \App\Intents |
| 14 |
* @author Ohidul Islam <wahid0003@gmail.com> |
| 15 |
* @link https://webappick.com |
| 16 |
* @license https://opensource.org/licenses/gpl-license.php GNU Public License |
| 17 |
* @category Intention |
| 18 |
*/ |
| 19 |
class ShippingIntent extends Intent { |
| 20 |
|
| 21 |
/** |
| 22 |
* Intent constructor. |
| 23 |
* |
| 24 |
* @param \Disco\App\Utility\Config $campaign Campaign Config. |
| 25 |
* @param \Disco\App\Utility\Settings $settings Global Settings. |
| 26 |
*/ |
| 27 |
public function __construct( $campaign, $settings ) { |
| 28 |
parent::__construct( $campaign, $settings ); |
| 29 |
|
| 30 |
$this->campaign = $campaign; |
| 31 |
$this->settings = $settings; |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Apply Product intention. |
| 36 |
* Product Discount Configuration. |
| 37 |
* |
| 38 |
* @param array $items Product Price. |
| 39 |
* @param \WC_Cart $cart Product Object. |
| 40 |
* @return string|null |
| 41 |
*/ |
| 42 |
public function get_discounts( $items, $cart ) {//phpcs:ignore |
| 43 |
|
| 44 |
// Check if Filter is passed then return free_shipping else return empty array. |
| 45 |
if ( !empty( $items ) ) { |
| 46 |
return 'free_shipping'; |
| 47 |
} |
| 48 |
|
| 49 |
return null; |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
/** |
| 54 |
* Get Shipping offers. |
| 55 |
* |
| 56 |
* @param array $items Cart Items. |
| 57 |
* @param \WC_Cart $cart Cart Object. |
| 58 |
* @return array $cart Cart Object. |
| 59 |
*/ |
| 60 |
public function get_offers( $items, $cart ) {//phpcs:ignore |
| 61 |
return $cart->get_cart_contents(); |
| 62 |
} |
| 63 |
|
| 64 |
} |
| 65 |
|