![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/extmag/shiplab/Model/Rule/Condition/Product/ |
<?php /** * Copyright © Extmag. All rights reserved. */ namespace Extmag\Shiplab\Model\Rule\Condition\Product; use Extmag\Shiplab\Model\Rule\Condition\Product; use Magento\Framework\Model\AbstractModel; use Magento\Rule\Model\Condition\Context; class Found extends Combine { /** * @param Context $context * @param Product $ruleConditionProduct * @param array $data */ public function __construct( Context $context, Product $ruleConditionProduct, array $data = [] ) { parent::__construct($context, $ruleConditionProduct, $data); $this->setType(Found::class); } /** * Load value options * * @return Found */ public function loadValueOptions() { $this->setValueOption([1 => __('FOUND'), 0 => __('NOT FOUND')]); return $this; } /** * Return as html * * @return string */ public function asHtml() { $html = $this->getTypeElement()->getHtml() . __( "If an item is %1 in the cart with %2 of these conditions true:", $this->getValueElement()->getHtml(), $this->getAggregatorElement()->getHtml() ); if ($this->getId() != '1') { $html .= $this->getRemoveLinkHtml(); } return $html; } /** * Validate * * @param AbstractModel $model * * @return bool * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function validate(AbstractModel $model) { $isValid = false; $items = $model->getAllItems()??$model->getQuote()->getAllItems(); foreach ($items as $item) { if (parent::validate($item)) { $isValid = true; break; } } return $isValid; } }