GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( b1489d...d608fb )
by Scott van
15:51
created

EbayEnterprise_Multishipping_Model_Observer   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 53
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handleSalesOrderSaveBefore() 0 5 1
B handleSalesConvertQuoteToOrder() 0 30 4
1
<?php
2
/**
3
 * Copyright (c) 2013-2014 eBay Enterprise, Inc.
4
 *
5
 * NOTICE OF LICENSE
6
 *
7
 * This source file is subject to the Open Software License (OSL 3.0)
8
 * that is bundled with this package in the file LICENSE.md.
9
 * It is also available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * @copyright   Copyright (c) 2013-2014 eBay Enterprise, Inc. (http://www.ebayenterprise.com/)
13
 * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
14
 */
15
16
class EbayEnterprise_Multishipping_Model_Observer
17
{
18
    /**
19
     * Ensure shipment amounts have been collected for the order before it
20
     * is saved.
21
     *
22
     * @param Varien_Event_Observer
23
     * @return self
24
     */
25
    public function handleSalesOrderSaveBefore(Varien_Event_Observer $observer)
26
    {
27
        $observer->getEvent()->getOrder()->collectShipmentAmounts();
28
        return $this;
29
    }
30
31
    /**
32
     * Collect discount amounts from quote addresses and apply them to the
33
     * newly created order.
34
     *
35
     * @param Varien_Event_Observer
36
     * @return self
37
     */
38
    public function handleSalesConvertQuoteToOrder(Varien_Event_Observer $observer)
39
    {
40
        $event = $observer->getEvent();
41
        $order = $event->getOrder();
42
        $quote = $event->getQuote();
43
44
        $discountAmount = 0.00;
45
        $baseDiscountAmount = 0.00;
46
        foreach ($quote->getAllAddresses() as $address) {
47
            $discountAmount += $address->getDiscountAmount();
48
            $baseDiscountAmount += $address->getBaseDiscountAmount();
49
50
            // Each address *may* have a discount description but the order
51
            // can only have one. The discount description appears to only apply
52
            // to discounts added with a coupon. OOTB Magento only supports a
53
            // single coupon per order. So, while each address may have a discount
54
            // description, any address that has one will have the same one -
55
            // the one coupon discount that can be applied. As the description
56
            // can be on any, all or none of the addresses, check each address
57
            // for one and take the description from the first address that has one.
58
            if (!$order->hasDiscountDescription() && $address->hasDiscountDescription()) {
59
                $order->setDiscountDescription($address->getDiscountDescription());
60
            }
61
        }
62
63
        $order->setDiscountAmount($discountAmount)
64
            ->setBaseDiscountAmount($baseDiscountAmount);
65
66
        return $this;
67
    }
68
}
69