ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Amasty Team
|
||||
* @copyright Copyright (c) Amasty (https://www.amasty.com)
|
||||
* @package Hide Price (Call for Price) for Magento 2
|
||||
*/
|
||||
|
||||
namespace Amasty\HidePrice\Plugin\Bundle\Block;
|
||||
|
||||
class Option
|
||||
{
|
||||
/**
|
||||
* @var \Amasty\HidePrice\Helper\Data
|
||||
*/
|
||||
private $helper;
|
||||
|
||||
public function __construct(
|
||||
\Amasty\HidePrice\Helper\Data $helper
|
||||
) {
|
||||
$this->helper = $helper;
|
||||
}
|
||||
|
||||
public function aroundRenderPriceString(
|
||||
\Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Option $subject,
|
||||
\Closure $proceed,
|
||||
$selection,
|
||||
$includeContainer = true
|
||||
) {
|
||||
if ($this->helper->isNeedHideProduct($subject->getProduct())) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $proceed($selection, $includeContainer);
|
||||
}
|
||||
|
||||
/**
|
||||
* remove + symbal
|
||||
* @param \Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Option $subject
|
||||
* @param $result
|
||||
* @return mixed
|
||||
*/
|
||||
public function afterGetSelectionTitlePrice(
|
||||
\Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Option $subject,
|
||||
$result
|
||||
) {
|
||||
$result = str_replace('<span class="price-notice">+</span>', '', $result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Amasty Team
|
||||
* @copyright Copyright (c) Amasty (https://www.amasty.com)
|
||||
* @package Hide Price (Call for Price) for Magento 2
|
||||
*/
|
||||
|
||||
namespace Amasty\HidePrice\Plugin\Bundle\Helper\Catalog\Product;
|
||||
|
||||
use \Magento\Bundle\Helper\Catalog\Product\Configuration;
|
||||
use \Magento\Catalog\Model\Product\Configuration\Item\ItemInterface;
|
||||
|
||||
/**
|
||||
* Class ConfigurationPlugin
|
||||
*/
|
||||
class ConfigurationPlugin
|
||||
{
|
||||
/**
|
||||
* @var \Amasty\HidePrice\Helper\Data
|
||||
*/
|
||||
private $helper;
|
||||
|
||||
public function __construct(
|
||||
\Amasty\HidePrice\Helper\Data $helper
|
||||
) {
|
||||
$this->helper = $helper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Configuration $subject
|
||||
* @param callable $proceed
|
||||
* @param ItemInterface $item
|
||||
* @return array
|
||||
*/
|
||||
public function aroundGetBundleOptions(Configuration $subject, callable $proceed, ItemInterface $item)
|
||||
{
|
||||
$options = $proceed($item);
|
||||
if ($this->helper->isNeedHidePrice($item->getProduct())) {
|
||||
foreach ($options as &$option) {
|
||||
if (isset($option['value']) && is_array($option['value'])) {
|
||||
$value = current($option['value']);
|
||||
$pricePosition = strpos($value, '<span class="price">');
|
||||
if ($pricePosition !== false) {
|
||||
$option['value'] = [substr($value, 0, $pricePosition)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user