Нужно добавить количество корзины и суб-количество на странице корзины - PullRequest
0 голосов
/ 20 января 2020

Мне нужно добавить количество товара и нужно получить атрибут расширения и умножить его на сумму.

Как получить атрибут расширения здесь. Нам нужны подробности относительно этой функциональности.

<?php
/**
 * Class RefundableAmount
 *
 * @package Emc\Packaging\Model\Total\Quote
 */
class RefundableAmount extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal
{
    /**
     * @var PriceCurrencyInterface
     */
    protected $_priceCurrency;

    /**
     * @var LoggerInterface
     */
    protected $logger;

    /**
     * RefundableAmount constructor.
     *
     * @param PriceCurrencyInterface $priceCurrency
     * @param LoggerInterface $logger
     */
    public function __construct(PriceCurrencyInterface $priceCurrency, LoggerInterface $logger)
    {
        $this->_priceCurrency = $priceCurrency;
        $this->logger = $logger;
    }

    /**
     *
     * @param \Magento\Quote\Model\Quote $quote
     * @param \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment
     * @param \Magento\Quote\Model\Quote\Address\Total $total
     * @return $this|bool
     */

    public function collect(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment, \Magento\Quote\Model\Quote\Address\Total $total)
    {
        parent::collect($quote, $shippingAssignment, $total);
        if (!empty($quote->getPayment()
            ->getMethod()))
        {
            $refundableAmount = ($quote->getSubtotal() * 20) / 100;
            $this
                ->logger
                ->info("refundable amount added to quote $refundableAmount");
            $this
                ->logger
                ->info("total Amount" . $quote->getBaseGrandTotal());
            $convertedPackagingPrice = $this
                ->_priceCurrency
                ->convert($refundableAmount);
            $total->setTotalAmount('refundable_amount', $convertedPackagingPrice);
            $total->setBaseTotalAmount('refundable_amount', $refundableAmount);
            $quote->setRefundableAmount($refundableAmount);
        }
        return $this;
    }

}

Пожалуйста, найдите мой код выше.

$refundableAmount = ($quote->getSubtotal() * extension_attribute_here) / 100;

Имя моего атрибута refundable_amount

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...