# disco/1.4.14/app/Intents/BulkIntent.php

Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO, version 1.4.14. 83 lines.

- Page: https://pluginprobe.com/plugins/disco/1.4.14/code/app/Intents/BulkIntent.php
- Raw: https://pluginprobe.com/plugins/disco/1.4.14/raw/app/Intents/BulkIntent.php
- Modified: 2024-12-02T12:43:08+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/disco/1.4.14/code/app/Intents/BulkIntent.php#L10-L20`.

```php
<?php
/**
 * @package    Disco
 * @subpackage \App\Intents
 */

namespace Disco\App\Intents;

/**
 * Class Cart
 *
 * @package    Disco
 * @subpackage \App\Intents
 * @author     Ohidul Islam <wahid0003@gmail.com>
 * @link       https://webappick.com
 * @license    https://opensource.org/licenses/gpl-license.php GNU Public License
 * @category   Intention
 */
class BulkIntent extends Intent {

    /**
	 * Intent constructor.
	 *
	 * @param \Disco\App\Utility\Config   $campaign Campaign Config.
	 * @param \Disco\App\Utility\Settings $settings Global Settings.
	 */
	public function __construct( $campaign, $settings ) {
		parent::__construct( $campaign, $settings );

		$this->campaign = $campaign;
		$this->settings = $settings;
	}

	/**
	 * Apply Bulk intention.
	 * Bulk Discount Configuration.
	 *
	 * @param array    $items Discount Applicable Cart Items.
	 * @param \WC_Cart $cart Cart.
	 * @return array
	 */
	public function get_discounts( $items, $cart ) {//phpcs:ignore
		return $this->get_item_discounts( $this->campaign, $items, $cart );
	}


	/**
	 * Get offers for Cart intention.
	 *
	 * @param array    $items Discount Applicable Cart Items.
	 * @param \WC_Cart $cart Cart.
	 * @return array|bool
	 */
	public function get_offers( $items, $cart ) { //phpcs:ignore
		if ( empty( $items ) ) {
			return false;
		}

		$offers = array();
		$rules  = $this->campaign->get_discount_rules();

		if ( is_array( $rules ) && ! empty( $rules ) ) {
			foreach ( $rules as $rule ) {
				$rule = (array) $rule;

				if ( 'percent' === $rule['discount_type'] ) {
					$discount = $rule['discount_value'] . '% off';
				} else {
					$discount = wc_price( $rule['discount_value'] ) . ' off';
				}

				$offers[] = array(
					'condition' => $rule['min'] . ' - ' . $rule['max'],
					'discount'  => '<b>' . $discount . '</b>',
				);
			}
		}

		return $offers;
	}

}

```
