PayPal\Api\Details::setShippingDiscount PHP Method

setShippingDiscount() public method

Amount being discounted for the shipping fee. Only supported when the payment_method is set to paypal.
public setShippingDiscount ( string | double $shipping_discount )
$shipping_discount string | double
    public function setShippingDiscount($shipping_discount)
    {
        NumericValidator::validate($shipping_discount, "Shipping Discount");
        $shipping_discount = FormatConverter::formatToPrice($shipping_discount);
        $this->shipping_discount = $shipping_discount;
        return $this;
    }

Usage Example

 /**
  * Build Amount
  *
  * @param Mage_Sales_Model_Quote $quote
  * @return Amount
  */
 protected function buildAmount($quote)
 {
     $details = new Details();
     $details->setShipping($quote->getShippingAddress()->getBaseShippingAmount())->setTax($quote->getBillingAddress()->getBaseTaxAmount() + $quote->getBillingAddress()->getBaseHiddenTaxAmount() + $quote->getShippingAddress()->getBaseTaxAmount() + $quote->getShippingAddress()->getBaseHiddenTaxAmount())->setSubtotal($quote->getBaseSubtotal());
     $totals = $quote->getTotals();
     if (isset($totals['discount']) && $totals['discount']->getValue()) {
         $details->setShippingDiscount(-$totals['discount']->getValue());
     }
     $amount = new Amount();
     $amount->setCurrency($quote->getBaseCurrencyCode())->setDetails($details)->setTotal($quote->getBaseGrandTotal());
     return $amount;
 }