mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-22 21:03:01 +09:00
remove redundant cart query
This commit is contained in:
1 parent
95a435456b
commit
16367a2a5c
1 file changed
+4
-10
@@ -460,18 +460,12 @@ class Service implements InjectionAwareInterface
|
||||
|
||||
public function createFromCart(\Model_Client $client, $gateway_id = null)
|
||||
{
|
||||
$cart = $this->getSessionCart();
|
||||
$cartProducts = $this->di['db']->find('CartProduct', 'cart_id = :cart_id', array(':cart_id' => $cart->id));
|
||||
if (count($cartProducts) == 0) {
|
||||
$cart = $this->getSessionCart();
|
||||
$ca = $this->toApiArray($cart);
|
||||
if (count($ca['items']) == 0) {
|
||||
throw new \Box_Exception('Can not checkout empty cart.');
|
||||
}
|
||||
|
||||
$ca = $this->toApiArray($cart);
|
||||
|
||||
$create_invoice = true;
|
||||
if ($ca['total'] == 0) {
|
||||
$create_invoice = false;
|
||||
}
|
||||
|
||||
$currency = $this->di['db']->getExistingModelById('Currency', $cart->currency_id, 'Currency not found.');
|
||||
|
||||
@@ -568,7 +562,7 @@ class Service implements InjectionAwareInterface
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($create_invoice) {
|
||||
if ($ca['total'] > 0) { //crete invoice if order total > 0
|
||||
|
||||
$invoiceService = $this->di['mod_service']('Invoice');
|
||||
$invoice_id = $invoiceService->prepareInvoice($client, array('client_id' => $client->id, 'items' => $invoice_items, 'gateway_id' => $gateway_id));
|
||||
|
||||
Reference in new issue
Block a user