Removes a coupon from the item.

@param null $code
342150
private function removeCouponFromItems($code = null)
    {
        foreach ($this->getItems() as $item) {
            if (isset($item->code) && (empty($code) || $item->code == $code)) {
                $item->code = null;
                $item->coupon = null;
            }
        }
    }
1163432
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 );
	}
349361
protected function compare($code, $expectedCode)
    {
        return ($expectedCode !== null && is_string($expectedCode) && $this->niceize($code) == $this->niceize($expectedCode));
    }
765198
public function invoices($code = null)
    {
        if (! $code) {
            $code = $this->data->code;
        }

        return $this->client->get('/{code}/invoices', [$code])
                            ->setDataKey('invoices')
                            ->getResults();
    }
177437
public function getCoupons($code = null)
    {
        $requestData = new Get\RequestData($code);
        $request = new Get\Request($requestData);

        $apiResponse = $this->sendRequest($request, Get\ApiResponse::class);
        /** @var Get\Response $response */
        $response = $apiResponse->getResponse();
        foreach ($response->getCoupons() as $coupon) {
            $validFrom = $coupon->getValidFrom();
            if ($validFrom !== null) {
                $validFrom->setTime(0, 0, 0);
            }

            $validTo = $coupon->getValidTo();
            if ($validTo !== null) {
                $validTo->setTime(0, 0, 0);
            }
        }

        return $apiResponse;
    }
1245243
public function setCode($code)
    {
        if ($code instanceof PagSeguroPaymentMethodCode) {
            $this->code = $code;
        } else {
            $this->code = new PagSeguroPaymentMethodCode($code);
        }
    }
97550
public function deleteTemplateByCode($templatecode)
    {
        $template = $this->loadByTemplateByCode($templatecode);
        if ($template->getId()) {
            $template->delete();
        }
    }
767183
public function removeSideMenuItem($owner, $code, $sideCode)
    {
        $itemKey = $this->makeItemKey($owner, $code);
        if (!isset($this->items[$itemKey])) {
            return false;
        }

        $mainItem = $this->items[$itemKey];
        unset($mainItem->sideMenu[$sideCode]);
    }
369149
public function delete($code) {
        $service = self::get($code);

        $deleteResult = Manager::delete($service->getId());
        if (!$deleteResult->isSuccess()) {
            $this->throwException(
                __METHOD__,
                'Error deleting delivery service [%s]: %s',
                $code,
                implode('; ', $deleteResult->getErrorMessages())
            );
        }
    }
740219
protected static function deleteFreeItemCouponByIdAsyncWithHttpInfo($free_item_coupon_id) 
    {
        $returnType = '';  
        $request = self::deleteFreeItemCouponByIdRequest($free_item_coupon_id); 

        return self::getHttpClient()
            ->sendAsync($request, self::createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    return [null, $response->getStatusCode(), $response->getHeaders()];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();
                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        $response->getBody()
                    );
                }
            );
    }
465455
private function removeChecksum($code)
    {
        $length = strlen($code);
        if ($length == 13 || $length == 10) {
            $code = substr_replace($code, "", -1);
            return $code;
        } elseif ($length == 12 || $length == 9) {
            return $code;
        } else {
            $this->setValid(false);
            $this->addError(self::ERROR_INVALID_LENGTH);
            return $code;
        }
    }
873693
public Coupon getCoupon(final String couponCode) {
        if (couponCode == null || couponCode.isEmpty())
            throw new RuntimeException("couponCode cannot be empty!");

        return doGET(Coupon.COUPON_RESOURCE + "/" + couponCode, Coupon.class);
    }
488003
protected function updateCurrency($code)
    {
        if (!$this->isError() && !$this->currency->update($code, $this->getSubmitted())) {
            $this->errorAndExit($this->text('Unexpected result'));
        }
    }
1286006
public function disable($code)
    {
        $promocode = Promocode::byCode($code)->first();

        if ($promocode === null) {
            throw new InvalidPromocodeException;
        }

        $promocode->expires_at = Carbon::now();

        return $promocode->save();
    }
1143595
public function validateCode($code)
    {
        $coupon = $this->_controller->getRepository()->find(array('code' => $code));

        if ($coupon && !$coupon->expired()) {
            $discount = $coupon->discount * 100;
            $this->setMessage(AnTranslator::sprintf('COM-SUBSCRIPTIONS-VALID-COUPON', $discount));
            return true;
        } else {
            $this->setMessage(AnTranslator::_('COM-SUBSCRIPTIONS-INVALID-COUPON'));
            return false;
        }
    }
921707
public static function discountIsValid($code)
    {
        $discount = Discount_Shortcuts_GetDiscountByCodeOrNull($code);
        if ($discount == null)
            return false;
        $engine = Discount_Shortcuts_GetEngineOrNull($discount->get_type());
        if ($engine == null)
            return false;
        return $engine->isValid($discount);
    }
766240
public static function removeVerificationGroup($code)
    {
        if (isset(self::config()->verification_groups[$code])) {
            unset(self::config()->verification_groups[$code]);
        }
    }