Failed Conditions
Pull Request — develop (#1)
by Carlo
03:42
created

Checkout::quoteServiceSubmitAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4286
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
/**
3
 * Checkout.php
4
 */
5
6
namespace Magefix\Fixture\Builder\Helper;
7
8
9
use Mage;
10
use Mage_Checkout_Model_Type_Onepage;
11
use Mage_Sales_Model_Quote;
12
13
class Checkout
14
{
15
    /**
16
     * @param array $checkoutMethodData
17
     *
18
     * @return bool
19
     *
20
     */
21
    public static function _isGuestCheckout(array $checkoutMethodData)
22
    {
23
        return self::_isCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_GUEST, $checkoutMethodData);
24
    }
25
26
    /**
27
     * @param array $checkoutMethodData
28
     *
29
     * @return bool
30
     *
31
     */
32
    public static function isRegisterCheckout(array $checkoutMethodData)
33
    {
34
        return self::_isCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER, $checkoutMethodData);
35
    }
36
37
    /**
38
     * @param array $checkoutMethodData
39
     *
40
     * @return bool
41
     *
42
     */
43
    public static function isCustomerCheckout(array $checkoutMethodData)
44
    {
45
        return self::_isCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_CUSTOMER, $checkoutMethodData);
46
    }
47
48
    /**
49
     * @param Mage_Sales_Model_Quote $quote
50
     *
51
     * @return Mage_Sales_Model_Order
52
     *
53
     */
54
    public static function quoteServiceSubmitAll(Mage_Sales_Model_Quote $quote)
55
    {
56
        $service = Mage::getModel('sales/service_quote', $quote);
57
        $service->submitAll();
58
59
        return $service->getOrder();
60
    }
61
62
    /**
63
     * @param $method
64
     * @param $checkoutMethodData
65
     *
66
     * @return bool
67
     */
68
    private static function _isCheckoutMethod($method, $checkoutMethodData)
69
    {
70
        $isGuestCheckout = false;
71
72
        if ($checkoutMethodData['method'] == $method) {
73
            $isGuestCheckout = true;
74
        }
75
76
        return $isGuestCheckout;
77
    }
78
}
79