Pregunta

Estoy aprendiendo Magento e intentando crear un método de envío que aparezca solo cuando el subtotal del carrito supera los $100.

lo intenté getSubTotal() en función collectRates(), entonces return false si el valor de retorno es menor que 100.Sin embargo, siempre regresa. 0.Supongo que no se había calculado en ese paso, ¿es cierto?

¿Y hay alguna otra manera de poder hacer lo que quería?

Por favor ayuda...¡Muchas gracias!

¿Fue útil?

Solución

su collectRates El método debería verse así.

public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
    //if method is disabled
    if (!$this->getConfigFlag('active')) {
        return false;
    }

    if ($request->getPackageValue() < 100) {
        return false;
    }
    /** @var Mage_Shipping_Model_Rate_Result $result */
    $result = Mage::getModel('shipping/rate_result');
    $method = Mage::getModel('shipping/rate_result_method');
    $method->setCarrier($this->_code); //add here the payment method code
    $method->setCarrierTitle($this->getConfigData('title')); //or you can add any title if it's not configurable
    $method->setPrice(your shiping cost here);
    $result->append($method);
    return $result;
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a magento.stackexchange
scroll top