/** * Delete a certain position from the basket * Used in multiple locations * * @param int $id Id of the basket line * @throws Enlight_Exception If entry could not be deleted from the database * @return null */ public function sDeleteArticle($id) { $id = (int) $id; $modus = $this->db->fetchOne('SELECT modus FROM s_order_basket WHERE id = ?', array($id)); if ($id && $id != "voucher") { $this->db->delete('s_order_basket', array('sessionID = ?' => $this->session->get('sessionId'), 'id = ?' => $id)); if (empty($modus)) { $this->sUpdateVoucher(); } } }
/** * Deletes all dummy customer entity */ private function deleteDummyCustomer(\Shopware\Models\Customer\Customer $customer) { $billingId = $this->db->fetchOne('SELECT id FROM s_user_billingaddress WHERE userID = ?', array($customer->getId())); $shippingId = $this->db->fetchOne('SELECT id FROM s_user_shippingaddress WHERE userID = ?', array($customer->getId())); if ($billingId) { $this->db->delete('s_user_billingaddress_attributes', 'billingID = ' . $billingId); $this->db->delete('s_user_billingaddress', 'id = ' . $billingId); } if ($shippingId) { $this->db->delete('s_user_shippingaddress_attributes', 'shippingID = ' . $shippingId); $this->db->delete('s_user_shippingaddress', 'id = ' . $shippingId); } $this->db->delete('s_core_payment_data', 'user_id = ' . $customer->getId()); $this->db->delete('s_user_attributes', 'userID = ' . $customer->getId()); $this->db->delete('s_user', 'id = ' . $customer->getId()); }
/** * Get shipping costs * Used in sBasket and Checkout controller * * @param array $country Array with a single country details * @return array|false Array with shipping costs data, or false on failure */ public function sGetPremiumShippingcosts($country = null) { $currencyFactor = empty($this->sSYSTEM->sCurrency['factor']) ? 1 : $this->sSYSTEM->sCurrency['factor']; // Determinate tax automatically $taxAutoMode = $this->config->get('sTAXAUTOMODE'); if (!empty($taxAutoMode)) { $discount_tax = $this->moduleManager->Basket()->getMaxTax(); } else { $discount_tax = $this->config->get('sDISCOUNTTAX'); $discount_tax = empty($discount_tax) ? 0 : (double) str_replace(',', '.', $discount_tax); } $surcharge_ordernumber = $this->config->get('sPAYMENTSURCHARGEABSOLUTENUMBER', 'PAYMENTSURCHARGEABSOLUTENUMBER'); $discount_basket_ordernumber = $this->config->get('sDISCOUNTNUMBER', 'DISCOUNT'); $discount_ordernumber = $this->config->get('sSHIPPINGDISCOUNTNUMBER', 'SHIPPINGDISCOUNT'); $percent_ordernumber = $this->config->get('sPAYMENTSURCHARGENUMBER', "PAYMENTSURCHARGE"); $this->db->delete('s_order_basket', array('sessionID = ?' => $this->session->offsetGet('sessionId'), 'modus IN (?)' => array(3, 4), 'ordernumber IN (?)' => array($surcharge_ordernumber, $discount_ordernumber, $percent_ordernumber, $discount_basket_ordernumber))); $basket = $this->sGetDispatchBasket(empty($country['id']) ? null : $country['id']); if (empty($basket)) { return false; } $country = $this->sGetCountry($basket['countryID']); if (empty($country)) { return false; } $payment = $this->sGetPaymentMean($basket['paymentID']); if (empty($payment)) { return false; } $amount = $this->db->fetchOne(' SELECT SUM((CAST(price as DECIMAL(10,2))*quantity)/currencyFactor) as amount FROM s_order_basket WHERE sessionID = ? GROUP BY sessionID ', array($this->session->offsetGet('sessionId'))); $this->handleBasketDiscount($amount, $currencyFactor, $discount_tax); $this->handleDispatchDiscount($basket, $currencyFactor, $discount_tax); $dispatch = $this->sGetPremiumDispatch((int) $this->session->offsetGet('sDispatch')); $payment = $this->handlePaymentMeanSurcharge($country, $payment, $currencyFactor, $dispatch, $discount_tax); if (empty($dispatch)) { return array('brutto' => 0, 'netto' => 0); } if (empty($this->sSYSTEM->sUSERGROUPDATA["tax"]) && !empty($this->sSYSTEM->sUSERGROUPDATA["id"])) { $dispatch['shippingfree'] = round($dispatch['shippingfree'] / (100 + $discount_tax) * 100, 2); } if (!empty($dispatch['shippingfree']) && $dispatch['shippingfree'] <= $basket['amount_display'] || empty($basket['count_article']) || !empty($basket['shippingfree']) && empty($dispatch['bind_shippingfree'])) { if (empty($dispatch['surcharge_calculation']) && !empty($payment['surcharge'])) { return array('brutto' => $payment['surcharge'], 'netto' => round($payment['surcharge'] * 100 / (100 + $this->config->get('sTAXSHIPPING')), 2)); } else { return array('brutto' => 0, 'netto' => 0); } } if (empty($dispatch['calculation'])) { $from = round($basket['weight'], 3); } elseif ($dispatch['calculation'] == 1) { $from = round($basket['amount'], 2); } elseif ($dispatch['calculation'] == 2) { $from = round($basket['count_article']); } elseif ($dispatch['calculation'] == 3) { $from = round($basket['calculation_value_' . $dispatch['id']], 2); } else { return false; } $result = $this->db->fetchRow("\n SELECT `value` , `factor`\n FROM `s_premium_shippingcosts`\n WHERE `from` <= ?\n AND `dispatchID` = ?\n ORDER BY `from` DESC\n LIMIT 1", array($from, $dispatch['id'])); if ($result === false) { return false; } if (!empty($dispatch['shippingfree'])) { $result['shippingfree'] = round($dispatch['shippingfree'] * $currencyFactor, 2); $difference = round(($dispatch['shippingfree'] - $basket['amount_display']) * $currencyFactor, 2); $result['difference'] = array("float" => $difference, "formated" => $this->moduleManager->Articles()->sFormatPrice($difference)); } $result['brutto'] = $result['value']; if (!empty($result['factor'])) { $result['brutto'] += $result['factor'] / 100 * $from; } $result['surcharge'] = $this->sGetPremiumDispatchSurcharge($basket); if (!empty($result['surcharge'])) { $result['brutto'] += $result['surcharge']; } $result['brutto'] *= $currencyFactor; $result['brutto'] = round($result['brutto'], 2); if (!empty($payment['surcharge']) && $dispatch['surcharge_calculation'] != 2 && (empty($basket['shippingfree']) || empty($dispatch['surcharge_calculation']))) { $result['surcharge'] = $payment['surcharge']; $result['brutto'] += $result['surcharge']; } if ($result['brutto'] < 0) { return array('brutto' => 0, 'netto' => 0); } if (empty($dispatch['tax_calculation'])) { $result['tax'] = $basket['max_tax']; } else { $result['tax'] = $dispatch['tax_calculation_value']; } $result['tax'] = (double) $result['tax']; $result['netto'] = round($result['brutto'] * 100 / (100 + $result['tax']), 2); return $result; }