cart icon indicating copy to clipboard operation
cart copied to clipboard

Bug when extraType = by_price_of_physical_products in Classes/Domain/Model/Cart/Service.php

Open vmans opened this issue 4 years ago • 0 comments

When you use virtual or downloadable products it's logical that these cost 0.00 euro.

When you add by_price_of_physical_products as extra type (to count only the gross price of products that are physically shipped), the base price is always counted.

This is my config example. Shipping costs 3 euro for actual shipments under 25 euro orders of simple products, thus excluding downloadable products.

plugin.tx_cart.shippings.countries {
    nl {
      preset = 1
      options {
          1 {
            title = Standaard
            extra >
            extra = by_price_of_physical_products
            extra {
              0 {
                value = 0.00
                extra = 3.00
              }
            }
            free.from = 25.00
            taxClassId = 3
            status = open
          }
      }
    }

It doesn't work. Not with only downloadable and not with mixed.

To make it work, in Services.php I made this change, I added

 if ((float)$conditionValue == 0) {
                        $extraValue['extra'] = 0;
                    }
            foreach ($this->config['extra'] as $extraKey => $extraValue) {
                if (is_array($extraValue) && ((float)$extraValue['value'] <= (float)$conditionValue)) {
                    if ((float)$conditionValue == 0) {
                        $extraValue['extra'] = 0;
                    }
                    $extra = new Extra(
                        $extraKey,
                        (float)$extraValue['value'],
                        (float)$extraValue['extra'],
                        $this->getTaxClass(),
                        $this->cart->getIsNetCart(),
                        $extraType,
                        $this
                    );
                }
            }

vmans avatar Jan 03 '22 01:01 vmans