public function addCoupon( $code, array $products = array() )
	{
		if( isset( $this->_coupons[$code] ) ) {
			throw new MShop_Order_Exception( sprintf( 'Duplicate coupon code "%1$s"', $code ) );
		}

		foreach( $products as $product )
		{
			$this->_checkProduct( $product );
			$this->_checkPrice( $product->getPrice() );
		}

		$this->_notifyListeners( 'addCoupon.before', $products );

		$this->_coupons[$code] = $products;

		foreach( $products as $product ) {
			$this->_products[] = $product;
		}

		$this->_modified = true;

		$this->_notifyListeners( 'addCoupon.after', $code );
	}
public function addCoupon( $code, array $products = array() )
	{
		if( isset( $this->_coupons[$code] ) ) {
			throw new MShop_Order_Exception( sprintf( 'Duplicate coupon code "%1$s"', $code ) );
		}

		foreach( $products as $product )
		{
			$this->_checkProduct( $product );
			$this->_checkPrice( $product->getPrice() );
		}

		$this->_notifyListeners( 'addCoupon.before', $products );

		$this->_coupons[$code] = $products;

		foreach( $products as $product ) {
			$this->_products[] = $product;
		}

		$this->_modified = true;

		$this->_notifyListeners( 'addCoupon.after', $code );
	}
public function addCoupon ( $ code , array $ products = array ( ) ) { if ( isset ( $ this -> _coupons [ $ code ] ) ) { throw new MShop_Order_Exception ( sprintf ( 'Duplicate coupon code "%1$s"' , $ code ) ) ; } foreach ( $ products as $ product ) { $ this -> _checkProduct ( $ product ) ; $ this -> _checkPrice ( $ product -> getPrice ( ) ) ; } $ this -> _notifyListeners ( 'addCoupon.before' , $ products ) ; $ this -> _coupons [ $ code ] = $ products ; foreach ( $ products as $ product ) { $ this -> _products [ ] = $ product ; } $ this -> _modified = true ; $ this -> _notifyListeners ( 'addCoupon.after' , $ code ) ; }
Adds a coupon code entered by the customer and the given product item to the basket.

@param string $code Coupon code
@param MShop_Order_Item_Base_Product_Interface[] $products List of coupon products
Adds a coupon code entered by the customer and the given product item to the basket .