function getDisplayPriceFront() { $display_price = $this->display_price_front; if ($this->use_extend_display_price_rule > 0) { $adv_user = JSFactory::getUserShop(); $country_id = $adv_user->country; $client_type = $adv_user->client_type; if (!$adv_user->user_id) { $adv_user = JSFactory::getUserShopGuest(); $country_id = $adv_user->country; $client_type = $adv_user->client_type; } if (!$country_id) { $country_id = $this->default_country; } if ($country_id) { $configDisplayPrice = JSFactory::getTable('configDisplayPrice', 'jshop'); $rows = $configDisplayPrice->getList(); foreach ($rows as $v) { if (in_array($country_id, $v->countries)) { if ($client_type == 2) { $display_price = $v->display_price_firma; } else { $display_price = $v->display_price; } } } } } return $display_price; }
function step5save() { $session = JFactory::getSession(); $jshopConfig = JSFactory::getConfig(); $db = JFactory::getDBO(); $checkout = JModelLegacy::getInstance('checkout', 'jshop'); $mainframe = JFactory::getApplication(); $checkout->checkStep(5); $checkagb = JRequest::getVar('agb'); JPluginHelper::importPlugin('jshoppingorder'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onLoadStep5save', array(&$checkagb)); $lang = JSFactory::getLang(); $user = JFactory::getUser(); if ($user->id) { $adv_user = JSFactory::getUserShop(); } else { $adv_user = JSFactory::getUserShopGuest(); } $cart = JModelLegacy::getInstance('cart', 'jshop'); $cart->load(); $cart->setDisplayItem(1, 1); $cart->setDisplayFreeAttributes(); if ($jshopConfig->check_php_agb && $checkagb != 'on') { JError::raiseWarning("", _JSHOP_ERROR_AGB); $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=step5', 0, 1, $jshopConfig->use_ssl)); return 0; } if (!$cart->checkListProductsQtyInStore()) { $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=cart&task=view', 1, 1)); return 0; } if (!$cart->checkCoupon()) { $cart->setRabatt(0, 0, 0); JError::raiseWarning("", _JSHOP_RABATT_NON_CORRECT); $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=cart&task=view', 1, 1)); return 0; } $orderNumber = $jshopConfig->next_order_number; $jshopConfig->updateNextOrderNumber(); $payment_method_id = $cart->getPaymentId(); $pm_method = JTable::getInstance('paymentMethod', 'jshop'); $pm_method->load($payment_method_id); $payment_method = $pm_method->payment_class; if ($jshopConfig->without_payment) { $pm_method->payment_type = 1; $paymentSystemVerySimple = 1; } else { $paymentsysdata = $pm_method->getPaymentSystemData(); $payment_system = $paymentsysdata->paymentSystem; if ($paymentsysdata->paymentSystemVerySimple) { $paymentSystemVerySimple = 1; } if ($paymentsysdata->paymentSystemError) { $cart->setPaymentParams(""); JError::raiseWarning("", _JSHOP_ERROR_PAYMENT); $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=step3', 0, 1, $jshopConfig->use_ssl)); return 0; } } $order = JTable::getInstance('order', 'jshop'); $arr_property = $order->getListFieldCopyUserToOrder(); foreach ($adv_user as $key => $value) { if (in_array($key, $arr_property)) { $order->{$key} = $value; } } $sh_mt_pr = JTable::getInstance('shippingMethodPrice', 'jshop'); $sh_mt_pr->load($cart->getShippingPrId()); $order->order_date = $order->order_m_date = getJsDate(); $order->order_tax = $cart->getTax(1, 1, 1); $order->setTaxExt($cart->getTaxExt(1, 1, 1)); $order->order_subtotal = $cart->getPriceProducts(); $order->order_shipping = $cart->getShippingPrice(); $order->order_payment = $cart->getPaymentPrice(); $order->order_discount = $cart->getDiscountShow(); $order->shipping_tax = $cart->getShippingPriceTaxPercent(); $order->setShippingTaxExt($cart->getShippingTaxList()); $order->payment_tax = $cart->getPaymentTaxPercent(); $order->setPaymentTaxExt($cart->getPaymentTaxList()); $order->order_package = $cart->getPackagePrice(); $order->setPackageTaxExt($cart->getPackageTaxList()); $order->order_total = $cart->getSum(1, 1, 1); $order->currency_exchange = $jshopConfig->currency_value; $order->vendor_type = $cart->getVendorType(); $order->vendor_id = $cart->getVendorId(); $order->order_status = $jshopConfig->default_status_order; $order->shipping_method_id = $cart->getShippingId(); $order->payment_method_id = $cart->getPaymentId(); $order->delivery_times_id = $sh_mt_pr->delivery_times_id; if ($jshopConfig->delivery_order_depends_delivery_product) { $order->delivery_time = $cart->getDelivery(); } if ($jshopConfig->show_delivery_date) { $order->delivery_date = $cart->getDeliveryDate(); } $order->coupon_id = $cart->getCouponId(); $pm_params = $cart->getPaymentParams(); if (is_array($pm_params) && !$paymentSystemVerySimple) { $payment_system->setParams($pm_params); $payment_params_names = $payment_system->getDisplayNameParams(); $order->payment_params = getTextNameArrayValue($payment_params_names, $pm_params); $order->setPaymentParamsData($pm_params); } $name = $lang->get("name"); $order->ip_address = $_SERVER['REMOTE_ADDR']; $order->order_add_info = JRequest::getVar('order_add_info', ''); $order->currency_code = $jshopConfig->currency_code; $order->currency_code_iso = $jshopConfig->currency_code_iso; $order->order_number = $order->formatOrderNumber($orderNumber); $order->order_hash = md5(time() . $order->order_total . $order->user_id); $order->file_hash = md5(time() . $order->order_total . $order->user_id . "hashfile"); $order->display_price = $jshopConfig->display_price_front_current; $order->lang = $jshopConfig->cur_lang; if ($order->client_type) { $order->client_type_name = $jshopConfig->user_field_client_type[$order->client_type]; } else { $order->client_type_name = ""; } if ($order->order_total == 0) { $pm_method->payment_type = 1; $jshopConfig->without_payment = 1; $order->order_status = $jshopConfig->payment_status_paid; } if ($pm_method->payment_type == 1) { $order->order_created = 1; } else { $order->order_created = 0; } if (!$adv_user->delivery_adress) { $order->copyDeliveryData(); } $dispatcher->trigger('onBeforeCreateOrder', array(&$order)); $order->store(); $dispatcher->trigger('onAfterCreateOrder', array(&$order)); if ($cart->getCouponId()) { $coupon = JTable::getInstance('coupon', 'jshop'); $coupon->load($cart->getCouponId()); if ($coupon->finished_after_used) { $free_discount = $cart->getFreeDiscount(); if ($free_discount > 0) { $coupon->coupon_value = $free_discount / $jshopConfig->currency_value; } else { $coupon->used = $adv_user->user_id; } $coupon->store(); } } $order->saveOrderItem($cart->products); $session->set("jshop_end_order_id", $order->order_id); $order_history = JTable::getInstance('orderHistory', 'jshop'); $order_history->order_id = $order->order_id; $order_history->order_status_id = $order->order_status; $order_history->status_date_added = $order->order_date; $order_history->customer_notify = 1; $order_history->store(); if ($pm_method->payment_type == 1) { $order->changeProductQTYinStock("-"); if ($jshopConfig->send_order_email) { $checkout->sendOrderEmail($order->order_id); } } $dispatcher->trigger('onEndCheckoutStep5', array(&$order)); $session->set("jshop_send_end_form", 0); if ($jshopConfig->without_payment) { $checkout->setMaxStep(10); $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=finish', 0, 1, $jshopConfig->use_ssl)); return 0; } $pmconfigs = $pm_method->getConfigs(); $task = "step6"; if (isset($pmconfigs['windowtype']) && $pmconfigs['windowtype'] == 2) { $task = "step6iframe"; $session->set("jsps_iframe_width", $pmconfigs['iframe_width']); $session->set("jsps_iframe_height", $pmconfigs['iframe_height']); } $checkout->setMaxStep(6); $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=' . $task, 0, 1, $jshopConfig->use_ssl)); }
function step5save(){ $mainframe =& JFactory::getApplication(); $this->_check(5); JPluginHelper::importPlugin('jshoppingorder'); $dispatcher =& JDispatcher::getInstance(); $lang = &JSFactory::getLang(); $user = &JFactory::getUser(); if ($user->id){ $adv_user = &JSFactory::getUserShop(); }else{ $adv_user = &JSFactory::getUserShopGuest(); } $cart = &JModel::getInstance('cart', 'jshop'); $cart->load(); $cart->setDisplayItem(1, 1); $cart->setDisplayFreeAttributes(); $session =& JFactory::getSession(); $jshopConfig = &JSFactory::getConfig(); $orderNumber = $jshopConfig->next_order_number; $jshopConfig->updateNextOrderNumber(); $db = &JFactory::getDBO(); $payment_method_id = $cart->getPaymentId(); $pm_method = &JTable::getInstance('paymentMethod', 'jshop'); $pm_method->load($payment_method_id); $payment_method = $pm_method->payment_class; if ($jshopConfig->without_payment){ $pm_method->payment_type = 1; $paymentSystemVerySimple = 1; }elseif (!file_exists($jshopConfig->path . 'payments/' . $payment_method."/".$payment_method. '.php')) { $paymentSystemVerySimple = 1; }else{ $paymentSystemVerySimple = 0; include_once ($jshopConfig->path . 'payments/' . $payment_method."/".$payment_method . '.php'); if (!class_exists($payment_method)) { $cart->setPaymentParams(""); JError::raiseWarning("",_JSHOP_ERROR_PAYMENT); $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=step3',0,1,$jshopConfig->use_ssl)); return 0; } } $order = &JTable::getInstance('order', 'jshop'); $arr_property = array('user_id','f_name','l_name','firma_name','client_type','firma_code','tax_number','email','street','zip','city','state','country','phone','mobil_phone','fax','title','ext_field_1','ext_field_2','ext_field_3','d_f_name','d_l_name','d_firma_name','d_email','d_street','d_zip','d_city','d_state','d_country','d_phone','d_mobil_phone','d_title','d_fax','d_ext_field_1','d_ext_field_2','d_ext_field_3'); foreach ($adv_user as $key => $value) { if(in_array($key, $arr_property)) { $order->$key = $value; } } $order->order_date = $order->order_m_date = date("Y-m-d H:i:s", mktime()); $order->order_tax = $cart->getTax(1, 1, 1); $order->setTaxExt($cart->getTaxExt(1, 1, 1)); $order->order_subtotal = $cart->getPriceProducts(); $order->order_shipping = $cart->getShippingPrice(); $order->order_payment = $cart->getPaymentPrice(); $order->order_discount = $cart->getDiscountShow(); $order->order_total = $cart->getSum(1, 1, 1); $order->currency_exchange = $jshopConfig->currency_value; $order->vendor_type = $cart->getVendorType(); $order->vendor_id = $cart->getVendorId(); $order->order_status = $jshopConfig->default_status_order; $order->shipping_method_id = $cart->getShippingId(); $order->payment_method_id = $cart->getPaymentId(); $pm_params = $cart->getPaymentParams(); if (is_array($pm_params) && !$paymentSystemVerySimple) { $payment_system = new $payment_method(); $payment_system->setParams($pm_params); $payment_params_names = $payment_system->getDisplayNameParams(); $order->payment_params = getTextNameArrayValue($payment_params_names, $pm_params); $order->setPaymentParamsData($pm_params); } $name = $lang->get("name"); $order->ip_address = $_SERVER['REMOTE_ADDR']; $order->order_add_info = JRequest::getVar('order_add_info',''); $order->currency_code = $jshopConfig->currency_code; $order->currency_code_iso = $jshopConfig->currency_code_iso; $order->order_number = $order->formatOrderNumber($orderNumber); $order->order_hash = md5(time().$order->order_total.$order->user_id); $order->file_hash = md5(time().$order->order_total.$order->user_id."hashfile"); $order->display_price = $jshopConfig->display_price_front_current; $order->lang = $jshopConfig->cur_lang; if ($order->client_type){ $order->client_type_name = $jshopConfig->user_field_client_type[$order->client_type]; }else{ $order->client_type_name = ""; } if ($pm_method->payment_type == 1){ $order->order_created = 1; }else { $order->order_created = 0; } if (!$adv_user->delivery_adress) $order->copyDeliveryData(); $dispatcher->trigger( 'onBeforeCreateOrder', array(&$order) ); if (!$order->store()){ JError::raiseWarning("", $order->getError()); $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=step5',0,1,$jshopConfig->use_ssl)); return 0; } $dispatcher->trigger( 'onAfterCreateOrder', array(&$order) ); if ($cart->getCouponId()){ $coupon = &JTable::getInstance('coupon', 'jshop'); $coupon->load($cart->getCouponId()); if ($coupon->finished_after_used){ $free_discount = $cart->getFreeDiscount(); if ($free_discount > 0){ $coupon->coupon_value = $free_discount / $jshopConfig->currency_value; }else{ $coupon->used = $adv_user->user_id; } $coupon->store(); } } $order->saveOrderItem($cart->products); $session->set("jshop_end_order_id", $order->order_id); $order_history = &JTable::getInstance('orderHistory', 'jshop'); $order_history->order_id = $order->order_id; $order_history->order_status_id = $order->order_status; $order_history->status_date_added = $order->order_date; $order_history->customer_notify = 1; $order_history->store(); if ($pm_method->payment_type == 1){ $order->changeProductQTYinStock("-"); } if ($pm_method->payment_type == 1){ $this->_sendOrderEmail($order->order_id); } $dispatcher->trigger( 'onEndCheckoutStep5', array(&$order) ); $session->set("jshop_send_end_form", 0); if ($jshopConfig->without_payment) { $this->_setMaxStep(10); $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=finish',0,1,$jshopConfig->use_ssl)); return 0; } $this->_setMaxStep(6); $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=step6',0,1,$jshopConfig->use_ssl)); }
public static function getAllTaxes() { static $rows; if (!is_array($rows)) { $jshopConfig = JSFactory::getConfig(); $dispatcher = JDispatcher::getInstance(); $_tax = JSFactory::getTable('tax', 'jshop'); $rows = JSFactory::getAllTaxesOriginal(); if ($jshopConfig->use_extend_tax_rule) { $country_id = 0; $adv_user = JSFactory::getUserShop(); $country_id = $adv_user->country; if ($jshopConfig->tax_on_delivery_address && $adv_user->delivery_adress && $adv_user->d_country) { $country_id = $adv_user->d_country; } $client_type = $adv_user->client_type; $enter_tax_id = $adv_user->tax_number != ""; if (!$country_id) { $adv_user = JSFactory::getUserShopGuest(); $country_id = $adv_user->country; if ($jshopConfig->tax_on_delivery_address && $adv_user->delivery_adress && $adv_user->d_country) { $country_id = $adv_user->d_country; } $client_type = $adv_user->client_type; $enter_tax_id = $adv_user->tax_number != ""; } if ($country_id) { $_rowsext = $_tax->getExtTaxes(); $dispatcher->trigger('beforeGetAllTaxesRowsext', array(&$_rowsext, &$country_id, &$adv_user, &$rows)); foreach ($_rowsext as $v) { if (in_array($country_id, $v->countries)) { if ($jshopConfig->ext_tax_rule_for == 1) { if ($enter_tax_id) { $rows[$v->tax_id] = $v->firma_tax; } else { $rows[$v->tax_id] = $v->tax; } } else { if ($client_type == 2) { $rows[$v->tax_id] = $v->firma_tax; } else { $rows[$v->tax_id] = $v->tax; } } } } $dispatcher->trigger('afterGetAllTaxesRowsext', array(&$_rowsext, &$country_id, &$adv_user, &$rows)); unset($_rowsext); } } $dispatcher->trigger('afterGetAllTaxes', array(&$rows)); } return $rows; }
/** * Update jshopping user info */ private function jshoppingUpdateUserInfo() { $adv_user = JSFactory::getUserShop(); if ($adv_user->user_id <= 0) { $adv_user = JSFactory::getUserShopGuest(); } if ($adv_user->title == 1) { $this->userGender = 'male'; } else { if ($adv_user->title == 2) { $this->userGender = 'female'; } } if (!empty($adv_user->f_name)) { $this->userFirstName = $adv_user->f_name; } if (!empty($adv_user->l_name)) { $this->userLastName = $adv_user->l_name; } if (!empty($adv_user->email)) { $this->userEmail = $adv_user->email; } if (!empty($adv_user->phone)) { $this->userPhone = $adv_user->phone; } if (!empty($adv_user->birthday)) { $this->userDateOfBirth = $adv_user->birthday; } }