function ceske_sluzby_heureka_overeno_zakazniky($order_id, $posted) { $api = get_option('wc_ceske_sluzby_heureka_overeno-api'); if (!empty($api)) { $order = new WC_Order($order_id); // https://github.com/heureka/heureka-overeno-php-api require_once dirname(__FILE__) . '/src/HeurekaOvereno.php'; $language = get_locale(); if ($language == "sk_SK") { $overeno = new HeurekaOvereno($api, HeurekaOvereno::LANGUAGE_SK); } else { $overeno = new HeurekaOvereno($api); } $overeno->setEmail($posted['billing_email']); $products = $order->get_items(); foreach ($products as $product) { $overeno->addProduct($product['name']); } $overeno->addOrderId($order_id); $overeno->send(); } }
function handleCreateOrder() { $order_info = NEnvironment::getSession('user_order_info'); $values = $order_info['values']; // dump($values);exit; //presmerovanie ak nieco nieje v poriadku $session = NEnvironment::getSession('cart'); if (empty($session->products)) { $this->redirect('default'); } if (empty($order_info['values'])) { $this->redirect('step2'); } //znama polick login na email $values['email'] = $values['login']; $values['id_lang'] = $this->id_lang; //odstranenie loginu unset($values['login']); //odstranenie terms_and_conditions unset($values['terms_and_conditions']); //odstranenie discount_hash // $discount_hash = $values['discount_hash']; if ($values['type'] == NULL) { $values['type'] = 0; } $values['user_discount'] = 0; // ak je prihlaseny setni id_user if ($this->user->isLoggedIn()) { $values['id_user'] = $this->user->getIdentity()->data['user_id']; $values['user_discount'] = $this->user->getIdentity()->data['discount']; } $cart_info = OrderModel::getCartInfo($session->products, $order_info['values']['id_delivery'], $order_info['values']['id_payment'], $this->context, false); $values['total_price'] = $cart_info['total_sum']; $values['total_price_with_tax'] = $cart_info['total_sum_with_tax']; $values['delivery_title'] = $cart_info['delivery_title']; $values['delivery_price'] = $cart_info['delivery_price']['price']; $values['delivery_tax'] = $cart_info['delivery_price']['tax']; $values['payment_title'] = $cart_info['payment_title']; $values['payment_price'] = $cart_info['payment_price']['price']; $values['payment_tax'] = $cart_info['payment_price']['tax']; //odstranenie id_delivery unset($values['id_delivery']); //odstranenie id_payment unset($values['id_payment']); $values['rate'] = Lang::get($this->id_lang)->rate; try { $id_order = OrderModel::createOrder($values, $session->products, $this->id_lang, $this->user); $conf = $this->context->parameters; $template = $this->template; $template->setFile(APP_DIR . '/FrontModule/templates/Order/OrderEmail.phtml'); $template->discount = false; $template->o = OrderModel::get($id_order); $mail = new MyMail(); $mail->addTo($values['email']); $mail->addBcc($conf['client_email']); $mail->setSubject(_('Objednávka č. ') . $id_order); $mail->setTemplate($template); $mail->send(); if ($conf['HEUREKA']['ENABLE'] == 1) { try { $overeno = new HeurekaOvereno($conf['HEURELA']['API_KEY'], HeurekaOvereno::LANGUAGE_SK); $overeno->setEmail($values['email']); foreach ($session->products as $id_product_param => $p) { $product = ProductModel::getProductIdentifyByParam($id_product_param, $this->id_lang, $this->user); $overeno->addProduct($product->name); } $overeno->send(); } catch (Exception $e) { } } //vymazanie z kosika $session = NEnvironment::getSession('cart'); unset($session->products); //vymazanie info o uzivatelovi unset($order_info['values']); $this->redirect('Cart:success'); } catch (OrderException $e) { $form->addError($e); } }