function display_account_last_actions() { global $wpdb; $output = ''; $user_id = get_current_user_id(); if (!empty($user_id)) { $query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_author = %d', WPSHOP_NEWTYPE_IDENTIFIER_ORDER, $user_id); $orders = $wpdb->get_results($query); if (!empty($orders)) { $orders_list = ''; foreach ($orders as $order) { $order_meta = get_post_meta($order->ID, '_order_postmeta', true); $order_number = !empty($order_meta) && !empty($order_meta['order_key']) ? $order_meta['order_key'] : ''; $order_date = !empty($order_meta) && !empty($order_meta['order_date']) ? mysql2date(get_option('date_format'), $order_meta['order_date'], true) : ''; $order_amount = !empty($order_meta) && !empty($order_meta['order_key']) ? wpshop_tools::formate_number($order_meta['order_grand_total']) . ' ' . wpshop_tools::wpshop_get_currency(false) : ''; $order_available_status = unserialize(WPSHOP_ORDER_STATUS); $order_status = !empty($order_meta) && !empty($order_meta['order_status']) ? __($order_available_status[$order_meta['order_status']], 'wpshop') : ''; ob_start(); require wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, WPS_ACCOUNT_PATH . WPS_ACCOUNT_DIR . "/templates/", "frontend", "account/account-dashboard-resume-element"); $orders_list .= ob_get_contents(); ob_end_clean(); } ob_start(); require_once wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, WPS_ACCOUNT_PATH . WPS_ACCOUNT_DIR . "/templates/", "frontend", "account/account-dashboard-resume"); $output = ob_get_contents(); ob_end_clean(); } } return $output; }
/** * Return the payment list part * @param integer $order_id * @return string */ public static function generate_received_payment_part($order_id) { $date_ouput_format = get_option('date_format') . ' ' . get_option('time_format'); $output = ''; $tpl_component = array(); $tpl_component['ORDER_RECEIVED_PAYMENT_ROWS'] = ''; if (!empty($order_id)) { $order_postmeta = get_post_meta($order_id, '_order_postmeta', true); if (!empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['received'])) { $wps_payment_option = get_option('wps_payment_mode'); foreach ($order_postmeta['order_payment']['received'] as $payment) { if (!empty($payment)) { $sub_tpl_component = array(); $sub_tpl_component['INVOICE_RECEIVED_PAYMENT_RECEIVED_AMOUNT'] = !empty($payment['received_amount']) ? number_format($payment['received_amount'], 2, ',', '') . ' ' . wpshop_tools::wpshop_get_currency() : 0; $sub_tpl_component['INVOICE_RECEIVED_PAYMENT_DATE'] = !empty($payment['date']) ? mysql2date($date_ouput_format, $payment['date'], true) : ''; $sub_tpl_component['INVOICE_RECEIVED_PAYMENT_METHOD'] = !empty($payment['method']) && is_array($wps_payment_option) && array_key_exists(strtolower($payment['method']), $wps_payment_option['mode']) && !empty($wps_payment_option['mode'][strtolower($payment['method'])]['name']) ? $wps_payment_option['mode'][strtolower($payment['method'])]['name'] : (!empty($payment['method']) ? __($payment['method'], 'wpshop') : ''); $sub_tpl_component['INVOICE_RECEIVED_PAYMENT_PAYMENT_REFERENCE'] = !empty($payment['payment_reference']) ? $payment['payment_reference'] : ''; $sub_tpl_component['INVOICE_RECEIVED_PAYMENT_INVOICE_REF'] = !empty($payment['invoice_ref']) ? $payment['invoice_ref'] : ''; $tpl_component['ORDER_RECEIVED_PAYMENT_ROWS'] .= wpshop_display::display_template_element('received_payment_row', $sub_tpl_component, array('type' => 'invoice_line', 'id' => 'partial_payment'), 'common'); } } } $output = wpshop_display::display_template_element('received_payment', $tpl_component, array('type' => 'invoice_line', 'id' => 'partial_payment'), 'common'); unset($tpl_component); } return $output; }
/** * Add product to the end user cart */ function ajax_wpshop_add_to_cart() { global $wpdb; $wpshop_cart = new wps_cart(); $product_id = isset($_POST['wpshop_pdt']) ? intval(wpshop_tools::varSanitizer($_POST['wpshop_pdt'])) : null; $product_qty = isset($_POST['wpshop_pdt_qty']) ? intval(wpshop_tools::varSanitizer($_POST['wpshop_pdt_qty'])) : 1; $cart_option = get_option('wpshop_cart_option', array()); $wpshop_variation_selected = !empty($_POST['wps_pdt_variations']) ? $_POST['wps_pdt_variations'] : array(); $from_administration = !empty($_POST['from_admin']) ? true : false; $order_id = !empty($_POST['wps_orders_order_id']) ? wpshop_tools::varSanitizer($_POST['wps_orders_order_id']) : null; // Check Cart Animation $cart_animation_choice = !empty($cart_option) && !empty($cart_option['animation_cart_type']) ? $cart_option['animation_cart_type'] : null; if (!empty($cart_option['total_nb_of_item_allowed']) && $cart_option['total_nb_of_item_allowed'][0] == 'yes') { $wpshop_cart->empty_cart(); } // Prepare Product to be added to cart $formatted_product = $wpshop_cart->prepare_product_to_add_to_cart($product_id, $product_qty, $wpshop_variation_selected); $product_to_add_to_cart = $formatted_product[0]; $new_pid = $formatted_product[1]; // Check cart Type $cart_type_for_adding = 'normal'; if (!empty($_POST['wpshop_cart_type'])) { switch (wpshop_tools::varSanitizer($_POST['wpshop_cart_type'])) { case 'quotation': $wpshop_cart_type = 'quotation'; break; default: $wpshop_cart_type = 'normal'; break; } } // Check Product image $product = get_post($product_id); $product_img = '<img src="' . WPSHOP_DEFAULT_PRODUCT_PICTURE . '" alt="no picture" />'; if (!empty($product_id)) { if ($product->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) { $parent_def = wpshop_products::get_parent_variation($product_id); $parent_post = !empty($parent_def['parent_post']) ? $parent_def['parent_post'] : array(); $product_title = !empty($parent_post) && !empty($parent_post->post_title) ? $parent_post->post_title : ''; $product_description = !empty($parent_post) && !empty($parent_post->post_content) ? $parent_post->post_content : ''; $product_img = !empty($parent_post->ID) ? get_the_post_thumbnail($parent_post->ID, 'thumbnail') : ''; } else { $product_title = $product->post_title; $product_description = $product->post_content; $product_img = get_the_post_thumbnail($product_id, 'thumbnail'); } } if (!empty($_POST['wps_orders_from_admin']) && $_POST['wps_orders_from_admin'] == true) { $order_meta = get_post_meta($order_id, '_order_postmeta', true); $return = $wpshop_cart->add_to_cart($product_to_add_to_cart, array($new_pid => $product_qty), $wpshop_cart_type, array(), true, $order_meta, $order_id); echo json_encode(array(true)); die; } else { $return = $wpshop_cart->add_to_cart($product_to_add_to_cart, array($new_pid => $product_qty), $wpshop_cart_type); } if ($return == 'success') { $cart_page_url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_cart_page_id'))); /** Template parameters */ $template_part = 'product_added_to_cart_message'; /** Build template */ $tpl_way_to_take = wpshop_display::check_way_for_template($template_part); if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) { /* Include the old way template part */ ob_start(); require_once wpshop_display::get_template_file($tpl_way_to_take[1]); $succes_message_box = ob_get_contents(); ob_end_clean(); } else { $succes_message_box = wpshop_display::display_template_element($template_part, array('PRODUCT_ID' => $product_id)); } unset($tpl_component); $action_after_add = $cart_option['product_added_to_cart'][0] == 'cart_page' ? true : false; if ($wpshop_cart_type == 'quotation') { $action_after_add = $cart_option['product_added_to_quotation'][0] == 'cart_page' ? true : false; } /** Product Price **/ $product_price = ''; if (!empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) && !empty($product_to_add_to_cart)) { $idp = ''; if (!empty($product_to_add_to_cart[$new_pid]['variations']) && count($product_to_add_to_cart[$new_pid]['variations']) < 2) { $idp = $product_to_add_to_cart[$new_pid]['variations'][0]; } else { if (strstr($new_pid, '__')) { $idp = $new_pid; } else { $idp = $product_to_add_to_cart[$new_pid]['id']; } } if (!empty($idp)) { $default_currency = wpshop_tools::wpshop_get_currency(false); $price_piloting_option = get_option('wpshop_shop_price_piloting'); $pr = !empty($price_piloting_option) && $price_piloting_option == 'HT' ? $_SESSION['cart']['order_items'][$new_pid]['item_pu_ht'] * $product_qty : $_SESSION['cart']['order_items'][$new_pid]['item_pu_ttc'] * $product_qty; $product_price = wpshop_tools::formate_number($pr) . $default_currency; } } /** Check if there are linked products **/ $related_products = get_post_meta($product_id, '_wpshop_product_related_products', true); $tpl_component = array(); $linked_products = ''; if (!empty($related_products)) { $linked_products = '<h2>' . __('Linked products', 'wpshop') . '</h2>'; $linked_products .= '<div class="modal_product_related">' . do_shortcode('[wpshop_related_products pid="' . $product_id . '" sorting="no"]') . '</div>'; } else { $linked_products = ''; } $message_confirmation = sprintf(__('%s has been add to the cart', 'wpshop'), $product->post_title); $modal_content = wpshop_display::display_template_element('wps_new_add_to_cart_confirmation_modal', array('RELATED_PRODUCTS' => $linked_products, 'PRODUCT_PICTURE' => $product_img, 'PRODUCT_TITLE' => $product_title, 'PRODUCT_PRICE' => $product_price, 'PRODUCT_DESCRIPTION' => $product_description)); $modal_footer_content = wpshop_display::display_template_element('wps_new_add_to_cart_confirmation_modal_footer', array()); $response = array(true, $succes_message_box, $action_after_add, $cart_page_url, $product_id, array($cart_animation_choice, $message_confirmation), array($product_img, $product_title, $linked_products, $product_price), $modal_content, $modal_footer_content); } else { $response = array(false, $return); } wp_die(json_encode($response)); }
/** * Save custom Order informations */ function save_order_custom_informations() { global $wpdb; // Check if it is an order save action if (!empty($_REQUEST['post_ID']) && get_post_type($_REQUEST['post_ID']) == WPSHOP_NEWTYPE_IDENTIFIER_ORDER) { //Define Customer ID $user_id = !empty($_REQUEST['wps_customer_id']) ? $_REQUEST['wps_customer_id'] : get_current_user_id(); // Order MetaData $order_meta = get_post_meta(intval($_REQUEST['post_ID']), '_order_postmeta', true); // Save General information of order's attached customer $wpdb->update($wpdb->posts, array('post_parent' => $user_id, 'post_status' => 'publish'), array('ID' => $_REQUEST['post_ID'])); update_post_meta($_REQUEST['post_ID'], '_wpshop_order_customer_id', $user_id); $order_meta['customer_id'] = $user_id; if (empty($order_meta['order_key'])) { $order_meta['order_key'] = !empty($order_meta['order_key']) ? $order_meta['order_key'] : (!empty($order_meta['order_status']) && $order_meta['order_status'] != 'awaiting_payment' ? wpshop_orders::get_new_order_reference() : ''); $order_meta['order_temporary_key'] = isset($order_meta['order_temporary_key']) && $order_meta['order_temporary_key'] != '' ? $order_meta['order_temporary_key'] : wpshop_orders::get_new_pre_order_reference(); } $order_meta['order_status'] = isset($order_meta['order_status']) && $order_meta['order_status'] != '' ? $order_meta['order_status'] : 'awaiting_payment'; $order_meta['order_date'] = isset($order_meta['order_date']) && $order_meta['order_date'] != '' ? $order_meta['order_date'] : current_time('mysql', 0); $order_meta['order_currency'] = wpshop_tools::wpshop_get_currency(true); // Order Attached Addresses save if (!empty($_REQUEST['wps_order_selected_address']['billing'])) { // Informations $order_informations = get_post_meta($_REQUEST['post_ID'], '_order_info', true); $order_informations = !empty($order_informations) ? $order_informations : array(); $billing_address_option = get_option('wpshop_billing_address'); $billing_address_option = !empty($billing_address_option) && !empty($billing_address_option['choice']) ? $billing_address_option['choice'] : ''; // Billing datas $order_informations['billing'] = array('id' => $billing_address_option, 'address_id' => $_REQUEST['wps_order_selected_address']['billing'], 'address' => get_post_meta($_REQUEST['wps_order_selected_address']['billing'], '_wpshop_address_metadata', true)); // Shipping datas if (!empty($_REQUEST['wps_order_selected_address']['shipping'])) { $shipping_address_option = get_option('wpshop_shipping_address_choice'); $shipping_address_option = !empty($shipping_address_option) && !empty($shipping_address_option['choice']) ? $shipping_address_option['choice'] : ''; $order_informations['shipping'] = array('id' => $shipping_address_option, 'address_id' => $_REQUEST['wps_order_selected_address']['shipping'], 'address' => get_post_meta($_REQUEST['wps_order_selected_address']['shipping'], '_wpshop_address_metadata', true)); } update_post_meta($_REQUEST['post_ID'], '_order_info', $order_informations); } // Add a Payment to Order MetaData if (!empty($_REQUEST['wpshop_admin_order_payment_received']) && !empty($_REQUEST['wpshop_admin_order_payment_received']['method']) && !empty($_REQUEST['wpshop_admin_order_payment_received']['date']) && !empty($_REQUEST['wpshop_admin_order_payment_received']['received_amount']) && ($_REQUEST['action_triggered_from'] == 'add_payment' || !empty($_REQUEST['wpshop_admin_order_payment_reference']))) { $received_payment_amount = $_REQUEST['wpshop_admin_order_payment_received']['received_amount']; // Payment Params $params_array = array('method' => $_REQUEST['wpshop_admin_order_payment_received']['method'], 'waited_amount' => $received_payment_amount, 'status' => 'payment_received', 'author' => $user_id, 'payment_reference' => $_REQUEST['wpshop_admin_order_payment_received']['payment_reference'], 'date' => current_time('mysql', 0), 'received_amount' => $received_payment_amount); $order_meta = wpshop_payment::check_order_payment_total_amount($_REQUEST['post_ID'], $params_array, 'completed', $order_meta, false); } //Round final amount $order_meta['order_grand_total'] = number_format(round($order_meta['order_grand_total'], 2), 2, '.', ''); $order_meta['order_total_ttc'] = number_format(round($order_meta['order_total_ttc'], 2), 2, '.', ''); $order_meta['order_amount_to_pay_now'] = number_format(round($order_meta['order_amount_to_pay_now'], 2), 2, '.', ''); // Payment Pre-Fill if (empty($order_meta['order_payment'])) { $order_meta['order_payment']['customer_choice']['method'] = ''; $order_meta['order_payment']['received'][] = array('waited_amount' => !empty($order_meta) && !empty($order_meta['order_grand_total']) ? number_format($order_meta['order_grand_total'], 2, '.', '') : 0); } // Apply a filter to make credit, notificate the customer and generate billing actions $order_meta = apply_filters('wps_order_saving_admin_extra_action', $order_meta, $_REQUEST); // Save Shipping informations & Order status update_post_meta($_REQUEST['post_ID'], '_wpshop_order_shipping_date', $order_meta['order_shipping_date']); update_post_meta($_REQUEST['post_ID'], '_wpshop_order_status', $order_meta['order_status']); // Save Metadata update_post_meta($_REQUEST['post_ID'], '_order_postmeta', $order_meta); } }
} else { if (empty($selected_shipping_method) && (!empty($shipping_modes) && !empty($shipping_modes['default_choice']) && $shipping_mode_id == $shipping_modes['default_choice'])) { $checked = 'checked="checked"'; $class = 'wps-activ'; } else { if ($count == 0 && empty($selected_shipping_method)) { $checked = 'checked="checked"'; $class = 'wps-activ'; } else { $checked = $class = ''; } } } $shipping_cost_are_free = false; $free_shipping_cost_alert = ''; $currency = wpshop_tools::wpshop_get_currency(); $cart_items = !empty($_SESSION) && !empty($_SESSION['cart']) && !empty($_SESSION['cart']['order_items']) ? $_SESSION['cart']['order_items'] : ''; $price_piloting = get_option('wpshop_shop_price_piloting'); if (!empty($cart_items)) { $wps_shipping = new wps_shipping(); $cart_weight = $wps_shipping->calcul_cart_weight($cart_items); $total_cart_ht_or_ttc_regarding_config = !empty($price_piloting) && $price_piloting == 'HT' ? $_SESSION['cart']['order_total_ht'] : $_SESSION['cart']['order_total_ttc']; $total_shipping_cost_for_products = $wps_shipping->calcul_cart_items_shipping_cost($cart_items); $shipping_cost = $wps_shipping->get_shipping_cost(count($cart_items), $total_cart_ht_or_ttc_regarding_config, $total_shipping_cost_for_products, $cart_weight, $shipping_mode_id) . ' ' . $currency; } if (!empty($shipping_mode['free_from'])) { $order_amount = !empty($price_piloting_option) && $price_piloting_option == 'HT' ? number_format((double) $_SESSION['cart']['order_total_ht'], 2, '.', '') : number_format((double) $_SESSION['cart']['order_total_ttc'], 2, '.', ''); if ($order_amount < $shipping_mode['free_from']) { $free_in = $shipping_mode['free_from'] - $order_amount; $shipping_cost .= ' ' . sprintf(__('Free in %s', 'wpshop'), $free_in . ' ' . $currency); } else {
/** * Define custom columns content display in post_type page for wpshop entities * * @param string $columns The default column for the post_type given in second parameter * @param integer $post_id The current post identifier to get information for display */ public static function custom_columns_content($column, $post_id) { $post_type = get_post_type($post_id); switch ($post_type) { case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT: $column_content = '<strong>-</strong>'; $product = wpshop_products::get_product_data($post_id); switch ($column) { case 'picture': $column_content = get_the_post_thumbnail($post_id, 'thumbnail'); break; case "product_stock": if (!empty($product['product_stock'])) { $column_content = (int) $product['product_stock'] . ' ' . __('unit(s)', 'wpshop'); } break; case "product_price": if (!empty($product['product_price'])) { $column_content = wpshop_prices::get_product_price($product, 'price_display', 'complete_sheet'); } break; case "tx_tva": if (!empty($product['product_price'])) { $column_content = number_format($product[$column], 2, '.', ' ') . ' %'; } break; default: if (!empty($product[$column])) { $attribute_prices = unserialize(WPSHOP_ATTRIBUTE_PRICES); if (in_array($column, $attribute_prices)) { $column_content = number_format($product[$column], 2, '.', ' ') . ' ' . wpshop_tools::wpshop_get_currency(); } else { $column_content = $product[$column]; } } break; } break; default: $column_content = ''; break; } echo $column_content; }
/** Resume cart Content **/ public static function resume_cart_content() { $output = ''; $currency = wpshop_tools::wpshop_get_currency(false); $cart_content = !empty($_SESSION) && !empty($_SESSION['cart']) ? $_SESSION['cart'] : array(); if (!empty($cart_content)) { $cart_items = !empty($cart_content['order_items']) ? $cart_content['order_items'] : array(); if (!empty($cart_items)) { if (!empty($cart_content['coupon_id'])) { $coupon_title = get_the_title($cart_content['coupon_id']); $coupon_value = wpshop_tools::formate_number($cart_content['order_discount_amount_total_cart']); } $order_total_before_discount = !empty($cart_content['order_grand_total_before_discount']) ? $cart_content['order_grand_total_before_discount'] : 0; $shipping_cost_ati = !empty($cart_content['order_shipping_cost']) ? $cart_content['order_shipping_cost'] : 0; $total_ati = $total_cart = !empty($cart_content['order_amount_to_pay_now']) ? $cart_content['order_amount_to_pay_now'] : 0; ob_start(); require_once wpshop_tools::get_template_part(WPS_CART_DIR, WPS_CART_TPL_DIR, "frontend", "resume-cart/resume-cart", "content"); $output = ob_get_contents(); ob_end_clean(); } else { $resume_cart_body = '<div class="wps-alert-info">' . __('Your cart is empty', 'wpshop') . '</div>'; } } else { $resume_cart_body = '<div class="wps-alert-info">' . __('Your cart is empty', 'wpshop') . '</div>'; } return $output; }
/** * Display a free Shipping cost alert in cart and shop */ function display_free_shipping_cost_alert() { global $wpdb; $output = ''; $cart = !empty($_SESSION['cart']) && is_array($_SESSION['cart']) ? $_SESSION['cart'] : null; $cart_option = get_option('wpshop_cart_option'); $price_piloting_option = get_option('wpshop_shop_price_piloting'); // Get a shipping mode, in order : selected, else default, else first, else shipping_rules. $shipping_modes = get_option('wps_shipping_mode'); if (!empty($shipping_modes) && !empty($shipping_modes['modes'])) { if (!empty($shipping_modes['default_choice']) && !empty($shipping_modes['modes'][$shipping_modes['default_choice']])) { $shipping_rules_option = $shipping_modes['modes'][$shipping_modes['default_choice']]; } elseif (!empty($shipping_modes['modes']['default_shipping_mode'])) { $shipping_rules_option = $shipping_modes['modes']['default_shipping_mode']; } else { $shipping_rules_option = reset($shipping_modes['modes']); } } else { $shipping_rules_option = get_option('wpshop_shipping_rules'); } if (!empty($shipping_rules_option) && !empty($shipping_rules_option['free_from']) && $shipping_rules_option['free_from'] > 0) { $free_shipping_cost_limit = $shipping_rules_option['free_from']; } if (!empty($cart_option) && !empty($cart_option['free_shipping_cost_alert'])) { if (!empty($cart['order_items']) && !empty($cart['order_grand_total'])) { $order_amount = !empty($price_piloting_option) && $price_piloting_option == 'HT' ? number_format((double) $cart['order_total_ht'], 2, '.', '') : number_format((double) $cart['order_total_ttc'], 2, '.', ''); if ($order_amount < $free_shipping_cost_limit) { $free_in = number_format((double) ($free_shipping_cost_limit - $order_amount), 2, '.', ''); $currency = wpshop_tools::wpshop_get_currency(); $output = sprintf(__('Free shipping cost in %s', 'wpshop'), $free_in . ' ' . $currency); } else { $output = __('Free shipping cost', 'wpshop'); } } } echo $output; }
/** * Generate barcode image * @param object $barcode Instance of wps_barcodegen * @param string $meta Numerical code of barcode * @param string $type Texte for complete message * @param string $price Price of product * @param string $title Title of product */ public function generate_image(&$barcode, $meta, $type, $price, $title, $post_ID = 0) { if (!empty($meta)) { $barcode->setGenerateCode($meta); $binCode = $barcode->getBinCode(); $px = 3.779528; $x = round(66 * $px); //249.449 px $y = round(50 * $px); //188.976 px $bar_size = round(63.393 / 72); //0.880 px $len = 0; $test = ''; while ($len !== strlen($binCode)) { $test .= substr($binCode, $len, 7) . ' '; $len = $len + 7; } $im = imagecreate($x, $y); $background_color = imagecolorallocate($im, 255, 255, 255); $start = round(5.79 * $px); //21.883 /*Write First left guard*/ $this->imgNormalGuard($im, $start, $start + $bar_size, imagecolorallocate($im, 0, 0, 0)); $this->imgNormalGuard($im, $start + $bar_size * 2, $start + $bar_size * 3, imagecolorallocate($im, 255, 255, 255)); $this->imgNormalGuard($im, $start + $bar_size * 4, $start + $bar_size * 5, imagecolorallocate($im, 0, 0, 0)); $pos = $start + $bar_size * 7; $newPos = $pos + $bar_size; /*Write left barcode*/ for ($i = 0; $i < 42; $i++) { if (substr($binCode, $i, 1) === '0') { $color = imagecolorallocate($im, 255, 255, 255); } else { $color = imagecolorallocate($im, 0, 0, 0); } $this->imgSymbole($im, $pos, $newPos, $color); $newPos = $pos + $bar_size; $pos = $newPos + $bar_size; } /*Writer center guard*/ $pos = $newPos; $this->imgNormalGuard($im, $pos, $newPos + $bar_size, imagecolorallocate($im, 255, 255, 255)); $this->imgNormalGuard($im, $pos + $bar_size * 2, $newPos + $bar_size * 3, imagecolorallocate($im, 0, 0, 0)); $this->imgNormalGuard($im, $pos + $bar_size * 4, $newPos + $bar_size * 5, imagecolorallocate($im, 255, 255, 255)); $this->imgNormalGuard($im, $pos + $bar_size * 6, $newPos + $bar_size * 7, imagecolorallocate($im, 0, 0, 0)); $this->imgNormalGuard($im, $pos + $bar_size * 8, $newPos + $bar_size * 9, imagecolorallocate($im, 255, 255, 255)); $pos = $newPos + $bar_size * 10; /*Write right barcode*/ for ($i = 42; $i < 84; $i++) { if (substr($binCode, $i, 1) === '0') { $color = imagecolorallocate($im, 255, 255, 255); } else { $color = imagecolorallocate($im, 0, 0, 0); } $newPos = $pos + $bar_size; $this->imgSymbole($im, $pos, $newPos, $color); $pos = $newPos + $bar_size; } /*Write right guard*/ $pos = $newPos + $bar_size; $this->imgNormalGuard($im, $pos, $pos + $bar_size, imagecolorallocate($im, 0, 0, 0)); $this->imgNormalGuard($im, $pos + $bar_size * 2, $pos + $bar_size * 3, imagecolorallocate($im, 255, 255, 255)); $this->imgNormalGuard($im, $pos + $bar_size * 4, $pos + $bar_size * 5, imagecolorallocate($im, 0, 0, 0)); $textSize = 16; $font = WPS_BARCODE_PATH . '/arialbd.ttf'; imagettftext($im, $textSize, 0, 8, $y - $start - 5, imagecolorallocate($im, 0, 0, 0), $font, substr($meta, 0, 1)); $continue = true; $i = 28; $j = 0; /*Write left number code*/ while ($j < 5) { $j = $j + 1; imagettftext($im, $textSize, 0, $i, $y - $start - 5, imagecolorallocate($im, 0, 0, 0), $font, substr($meta, $j, 1)); $i = $i + 14; } /*Write right number code*/ while ($j < 11) { $j = $j + 1; imagettftext($im, $textSize, 0, $i + 6, $y - $start - 5, imagecolorallocate($im, 0, 0, 0), $font, substr($meta, $j, 1)); $i = $i + 15; } imagettftext($im, $textSize, 0, $i + 4, $y - $start - 5, imagecolorallocate($im, 0, 0, 0), $font, substr($meta, $j + 1, 1)); /*Write ref product and price*/ $textSize = 12; $currency = wpshop_tools::wpshop_get_currency() === '€' ? "€" : wpshop_tools::wpshop_get_currency(); if ($type === __('coupon', 'wps_barcode')) { $coupon_postmeta = get_post_meta($post_ID, 'wpshop_coupon_discount_type'); if ($coupon_postmeta[0] === 'percent') { $price = $price . ' %'; } else { $price = sprintf(number_format($price, 2) . ' ' . $currency); } } else { $price = sprintf(number_format($price, 2) . ' ' . $currency); } imagettftext($im, $textSize, 0, 20, round(6 * $px), imagecolorallocate($im, 0, 0, 0), $font, $title); imagettftext($im, $textSize, 0, $x / 2 + 40, round(6 * $px), imagecolorallocate($im, 0, 0, 0), $font, $price); ob_start(); imagepng($im); $img = ob_get_clean(); echo '<p><img src="data:image/png;base64,' . base64_encode($img) . '" id="barcode" width="160" height="90" /></p>'; echo '<p style="text-align: right"><button class="button ' . 'button-primary button-large" type="button"' . 'id="print_barcode">' . __('Print', 'wps_barcode') . '</button></p>'; wp_mkdir_p(WPS_BARCODE_UPLOAD); file_put_contents(WPS_BARCODE_UPLOAD . $meta . '.png', $img); /*Generate ODT File*/ try { if (!class_exists('Odf')) { require_once WPS_BARCODE_PATH . '/librairies/odtphp/odf.php'; } $odf = new Odf(WPS_BARCODE_PATH . 'assets/medias/avery_a4_991_677.ott'); $odf->setImage('barcode', WPS_BARCODE_UPLOAD . $meta . '.png'); $odf->saveToDisk(WPS_BARCODE_UPLOAD . $meta . '.odt'); } catch (Exception $e) { echo __('Generation problem', 'wps_barcode'); } } else { echo '<p>' . sprintf(__('None bardcode generated as you did create %s.', 'wps_barcode'), $type) . '</p>'; } }
/** * Fill a template with given element. Replace some code by content before output the html * * @param string $template_to_fill The complete html code we want to display with element to change * @param array $feed The different element to put in place of the code into the tempalte part * * @return string The html code to display */ public static function feed_template($template_to_fill, $feed) { /* Add general element */ $feed['CURRENCY'] = wpshop_tools::wpshop_get_currency(); $feed['CURRENCY_CHOOSEN'] = wpshop_tools::wpshop_get_currency(); $feed['CURRENCY_SELECTOR'] = wpshop_attributes_unit::wpshop_shop_currency_list_field(); $feed['CART_LINK'] = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_cart_page_id'))); $available_key = array(); foreach ($feed as $element => $value) { $available_key[] = '{WPSHOP_' . $element . '}'; if (!is_array($value)) { $template_to_fill = str_replace('{WPSHOP_' . $element . '}', $value, $template_to_fill); } } if (WPSHOP_DISPLAY_AVAILABLE_KEYS_FOR_TEMPLATE) { $template_to_fill = '<!-- Available keys : ' . implode(' / ', $available_key) . ' -->' . $template_to_fill; } return $template_to_fill; }
function pre_footer($order_id) { // On r�cup�re les infos du magasin $store = get_option('wpshop_company_info', array()); $store_name = $store['company_name']; $society_type = $store['company_legal_statut']; $society_capital = $store['company_capital']; $siret = $store['company_siret']; $tva_intra = $store['company_tva_intra']; $currency = wpshop_tools::wpshop_get_currency(true); $this->SetFont('', '', 10); $this->SetXY(10, -50); if (isset($store['company_member_of_a_approved_management_center']) && $store['company_member_of_a_approved_management_center']) { $this->MultiCell(190, 4, utf8_decode(__('Member of an approved management center, accepting as such payments by check.', 'wpshop')), 0, 'L', FALSE); $this->Ln(); } $this->MultiCell(190, 4, utf8_decode(__('Law 83-629 of 07.12.83, Art. 8: "The administrative authorization does not confer any official character to the company or persons who benefit. It is in no way the responsibility of government."', 'wpshop')), 0, 'L', FALSE); $this->Ln(); $this->MultiCell(190, 4, utf8_decode($store_name . ', ' . $society_type . __(' capital of ', 'wpshop') . $society_capital . ' ' . $currency . '. SIRET : ' . $siret . '. TVA Intracommunautaire : ' . $tva_intra), 0, 'L', FALSE); }
<?php if (!empty($discount_data['type']) && ($discount_data['type'] == 'discount_amount' || $discount_data['type'] == 'discount_rate')) { ?> <span class="wps-badge-big-bottomLeft-rouge"> -<?php echo wpshop_tools::formate_number($discount_data['value']); echo $discount_data['type'] == 'discount_amount' ? wpshop_tools::wpshop_get_currency(false) : '<span>%</span>'; ?> </span> <?php }
/** * Partial payment configuration area display */ public static function partial_payment() { $output = ''; $partial_payment_current_config = get_option('wpshop_payment_partial', array('for_all' => array())); $partial_for_all_is_activate = false; if (!empty($partial_payment_current_config) && !empty($partial_payment_current_config['for_all']) && !empty($partial_payment_current_config['for_all']['activate'])) { $partial_for_all_is_activate = true; } $output .= ' <input type="checkbox" name="wpshop_payment_partial[for_all][activate]"' . ($partial_for_all_is_activate ? ' checked="checked"' : '') . ' id="wpshop_payment_partial_on_command_activation_state" /> <label for="wpshop_payment_partial_on_command_activation_state" >' . __('Activate partial command for all order', 'wpshop') . '</label><a href="#" title="' . __('If you want that customer pay a part o f total amount of there order, check this box then fill fields below', 'wpshop') . '" class="wpshop_infobulle_marker">?</a> <div class="wpshop_partial_payment_config_container' . ($partial_for_all_is_activate ? '' : ' wpshopHide') . '" id="wpshop_partial_payment_config_container" > <div class="alignleft" > ' . __('Value of partial payment', 'wpshop') . '<br/> <input type="text" value="' . (!empty($partial_payment_current_config) && !empty($partial_payment_current_config['for_all']) && !empty($partial_payment_current_config['for_all']['value']) ? $partial_payment_current_config['for_all']['value'] : '') . '" name="wpshop_payment_partial[for_all][value]" /> </div> <div class="" > ' . __('Type of partial payment', 'wpshop') . '<br/> <select name="wpshop_payment_partial[for_all][type]" > <option value="percentage"' . (!empty($partial_payment_current_config) && !empty($partial_payment_current_config['for_all']) && (empty($partial_payment_current_config['for_all']['type']) || $partial_payment_current_config['for_all']['type'] == 'percentage') ? ' selected="selected"' : '') . ' >' . __('%', 'wpshop') . '</option> <option value="amount"' . (!empty($partial_payment_current_config) && !empty($partial_payment_current_config['for_all']) && !empty($partial_payment_current_config['for_all']['type']) && $partial_payment_current_config['for_all']['type'] == 'amount' ? ' selected="selected"' : '') . ' >' . wpshop_tools::wpshop_get_currency() . '</option> </select> </div> </div>'; echo $output; }
"> <?php if ($order->_order_postmeta['order_key']) { if ($order->_order_postmeta['order_invoice_ref']) { $link = $order->_order_postmeta['order_invoice_ref']; } else { $link = $order->_order_postmeta['order_key']; } } else { $link = __('Order summary ', 'wpshop'); } echo $link; ?> </a> <span class="price_order"><?php echo number_format(round($order->_order_postmeta['order_grand_total'], 2), 2, '.', '') . ' ' . wpshop_tools::wpshop_get_currency(false); ?> </span> <span class="date_order"><?php echo date("d/m/Y | H:i:s", strtotime($order->_order_postmeta['order_date'])); ?> </span> <?php if ($order->_order_postmeta['order_invoice_ref']) { ?> <span class="invoice_order"> <a href="<?php echo WPSHOP_TEMPLATES_URL; ?> invoice.php?order_id=<?php echo $order->ID;
/** * Order content Template * @param integer $order_id : Order ID * @return string */ function order_content_template_for_mail($order_id) { $message = ''; if (!empty($order_id)) { $currency_code = wpshop_tools::wpshop_get_currency(false); $orders_infos = get_post_meta($order_id, '_order_postmeta', true); ob_start(); require wpshop_tools::get_template_part(WPS_MESSAGE_DIR, $this->template_dir, "backend/mails", "order_content_mail_template"); $message .= ob_get_contents(); ob_end_clean(); } return $message; }
/** Display all cart rules **/ function display_cart_rules($rules) { global $wpdb; $output = ''; if (!empty($rules)) { $tpl_component['MEDIAS_ICON_URL'] = WPSHOP_MEDIAS_ICON_URL; $tpl_component['CART_RULES_LINE'] = ''; foreach (unserialize($rules) as $k => $rule) { $sub_tpl_component['CART_RULE_LINE_CART_LIMEN'] = $k; switch ($rule['discount_type']) { case 'absolute_discount': $discount_type = __('Absolute discount', 'wpshop'); $discount_value = $rule['discount_value'] . ' ' . wpshop_tools::wpshop_get_currency(); break; case 'percent_discount': $discount_type = __('Percent discount', 'wpshop'); $discount_value = $rule['discount_value'] . ' %'; break; case 'gift_product': $discount_type = __('Product gift', 'wpshop'); $product = get_post($rule['discount_value']); if ($product->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) { $parent_product_infos = wpshop_products::get_parent_variation($product->ID); if (!empty($parent_product_infos) && !empty($parent_product_infos['parent_post'])) { $parent_post_infos = $parent_product_infos['parent_post']; $product_title = $parent_post_infos->post_title; $product_options = get_post_meta($product->ID, '_wpshop_variations_attribute_def', true); if (!empty($product_options) && is_array($product_options)) { $option_name = ''; foreach ($product_options as $k => $product_option) { $query = $wpdb->prepare('SELECT frontend_label FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s', $k); $option_name .= $wpdb->get_var($query) . ' '; $query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id= %d', $product_option); $option_name .= $wpdb->get_var($query) . ' '; } $discount_value = $product_title . ' (' . $option_name . ')'; } } } else { $discount_value = $product->post_title; } break; default: $discount_type = ''; $discount_value = $rule['discount_value']; break; } $sub_tpl_component['CART_RULE_LINE_DISCOUNT_TYPE'] = $discount_type; $sub_tpl_component['CART_RULE_LINE_DISCOUNT_VALUE'] = $discount_value; $sub_tpl_component['CART_RULE_LINE_CUSTOMER_GROUP'] = !empty($rule['customer_group']) ? $rule['customer_group'] : __('All customers groups', 'wpshop'); $sub_tpl_component['CART_RULE_ID'] = str_replace('.', '_', $sub_tpl_component['CART_RULE_LINE_CART_LIMEN']); $sub_tpl_component['MEDIAS_ICON_URL'] = WPSHOP_MEDIAS_ICON_URL; $tpl_component['CART_RULES_LINE'] .= wpshop_display::display_template_element('cart_rules_line', $sub_tpl_component, array(), 'admin'); unset($sub_tpl_component); } $output = wpshop_display::display_template_element('cart_rules_display', $tpl_component, array(), 'admin'); } return $output; }
</script> <ul class="wps_statistics_legend"> <?php $i = 0; foreach ($customer_recap as $customer_id => $customer) { if ($i < 8) { $user_data = get_userdata($customer_id); $customer_name = !empty($user_data) && !empty($user_data->last_name) ? strtoupper($user_data->last_name) : ''; $customer_name .= !empty($user_data) && !empty($user_data->first_name) ? ' ' . $user_data->first_name : ''; $customer_email = !empty($user_data) && !empty($user_data->user_email) ? ' - ' . $user_data->user_email : ''; ?> <li><div style="background : <?php echo $colors[$i]; ?> ;" class="legend_indicator"></div><?php echo $customer_name . ' ' . $customer_email . ' (' . number_format($customer, 2, '.', '') . ' ' . wpshop_tools::wpshop_get_currency(false); ?> )</li> <?php } } ?> </ul> <?php } else { ?> <div class="wps-alert-info"><?php _e('There is no best customer for the moment', 'wpshop'); ?> </div> <?php
<?php $company_infos = get_option('wpshop_company_info'); $amount = !empty($_SESSION['cart']['order_amount_to_pay_now']) ? wpshop_tools::formate_number($_SESSION['cart']['order_amount_to_pay_now']) : 0; ?> <div class="wps-boxed"> <p><?php _e('Thank you ! Your order has been placed and you will receive a confirmation email shortly.', 'wpshop'); ?> </p> <p><?php echo sprintf(__('You have to send the check with an amount of %s to about "%s" to the adress :', 'wpshop'), $amount . ' ' . wpshop_tools::wpshop_get_currency(false), !empty($company_infos['company_name']) ? $company_infos['company_name'] : ''); ?> </p> <p><?php echo !empty($company_infos['company_name']) ? $company_infos['company_name'] : ''; ?> <br/> <?php echo !empty($company_infos['company_street']) ? $company_infos['company_street'] : ''; ?> <br/> <?php echo !empty($company_infos['company_postcode']) ? $company_infos['company_postcode'] : ''; ?> <?php echo !empty($company_infos['company_city']) ? $company_infos['company_city'] : ''; ?> <br/> <?php echo !empty($company_infos['company_country']) ? $company_infos['company_country'] : '';
/** * Allows to inform customer that he would pay a partial amount on this order * * @param float $current_order_total The current order total to pay before partial amount calcul * @return array The amount to pay / A html output with amount to pay and different information */ function partial_payment_calcul($current_order_total) { $output = ''; $tpl_component = array(); /** Get current configuration */ $partial_payment_configuration = get_option('wpshop_payment_partial', array('for_all' => array())); if (!empty($partial_payment_configuration['for_all']) && !empty($partial_payment_configuration['for_all']['activate']) && $partial_payment_configuration['for_all']['activate'] == 'on') { $amount_of_partial_payment = 0; if (!empty($partial_payment_configuration['for_all']['value'])) { $amount_of_partial_payment = $partial_payment_configuration['for_all']['value']; } $partial_amount_to_pay = 0; $type_of_partial_payment = null; if (!empty($partial_payment_configuration['for_all']) && !empty($partial_payment_configuration['for_all']['type'])) { switch ($partial_payment_configuration['for_all']['type']) { case 'percentage': $type_of_partial_payment = '%'; $partial_amount_to_pay = $current_order_total * $amount_of_partial_payment / 100; break; case 'amount': $type_of_partial_payment = wpshop_tools::wpshop_get_currency(); $partial_amount_to_pay = $current_order_total - $amount_of_partial_payment; break; default: $type_of_partial_payment = wpshop_tools::wpshop_get_currency(); $partial_amount_to_pay = $current_order_total - $amount_of_partial_payment; break; } } $output['amount_of_partial_payment'] = $amount_of_partial_payment; $output['type_of_partial_payment'] = $type_of_partial_payment; $output['amount_to_pay'] = $partial_amount_to_pay; $tpl_component['CURRENT_ORDER_TOTAL_AMOUNT'] = $current_order_total; $tpl_component['PARTIAL_PAYMENT_CONFIG_AMOUNT'] = !empty($amount_of_partial_payment) ? $amount_of_partial_payment : ''; $tpl_component['PARTIAL_PAYMENT_CONFIG_TYPE'] = !empty($type_of_partial_payment) ? $type_of_partial_payment : ''; $tpl_component['PARTIAL_PAYMENT_AMOUNT'] = $partial_amount_to_pay; $output['display'] = wpshop_display::display_template_element('wpshop_partial_payment_display', $tpl_component); unset($tpl_component); } return $output; }
<?php if (!empty($orders)) { $order_status = unserialize(WPSHOP_ORDER_STATUS); $permalink_option = get_option('permalink_structure'); $currency = wpshop_tools::wpshop_get_currency(false); $account_page_id = get_option('wpshop_myaccount_page_id'); $color_label = array('awaiting_payment' => 'jaune', 'canceled' => 'rouge', 'partially_paid' => 'orange', 'incorrect_amount' => 'orange', 'denied' => 'rouge', 'shipped' => 'bleu', 'payment_refused' => 'rouge', 'completed' => 'vert', 'refunded' => 'rouge'); $wpshop_display_delete_order_option = get_option('wpshop_display_option'); ?> <?php if (!$from_admin) { ?> <span class="wps-h5"><?php _e('My last orders', 'wpshop'); ?> </span> <?php } ?> <div class="wps-table"> <div class="wps-table-header wps-table-row"> <div class="wps-table-cell"><?php _e('Date', 'wpshop'); ?> </div> <div class="wps-table-cell"><?php _e('Reference', 'wpshop');
/** Credit Slip Generation **/ function generate_credit_slip($order_id, $credit_ref) { $order_meta = get_post_meta($order_id, '_order_postmeta', true); $credit_meta = get_post_meta($order_id, '_wps_order_credit', true); if (!empty($credit_meta)) { foreach ($credit_meta as $id => $credit_def) { if ($credit_def['ref'] == $credit_ref) { $credit = $credit_meta[$id]; } } } $credit_date = !empty($credit) && !empty($credit['credit_date']) ? $credit['credit_date'] : ''; $logo_options = get_option('wpshop_logo'); $tpl_component['INVOICE_SUMMARY_MORE'] = ''; $tpl_component['INVOICE_LOGO'] = !empty($logo_options) ? '<img src="' . $logo_options . '" alt="" />' : ''; $tpl_component['INVOICE_ORDER_KEY_INDICATION'] = sprintf(__('Correction on order n. %s', 'wpshop'), $order_meta['order_key']); $tpl_component['INVOICE_ORDER_DATE_INDICATION'] = sprintf(__('Credit slip date %s', 'wpshop'), $credit_date); $tpl_component['INVOICE_VALIDATE_TIME'] = ''; $tpl_component['IBAN_INFOS'] = ''; $tpl_component['AMOUNT_INFORMATION'] = sprintf(__('Amount are shown in %s', 'wpshop'), wpshop_tools::wpshop_get_currency(true)); /** Header **/ $tpl_component['INVOICE_TITLE'] = __('Credit slip', 'wpshop'); $tpl_component['INVOICE_ORDER_INVOICE_REF'] = $credit_ref; $tpl_component['INVOICE_SENDER'] = wpshop_modules_billing::generate_invoice_sender_part(); $tpl_component['INVOICE_RECEIVER'] = wpshop_modules_billing::generate_receiver_part($order_id); /** Tab **/ $tpl_component['INVOICE_HEADER'] = wpshop_display::display_template_element('credit_slip_row_header', array(), array(), 'common'); /** Rows **/ $tpl_component['INVOICE_ROWS'] = ''; $total_HT = $total_TTC = 0; $credit_TVA = array(); if (!empty($credit['items'])) { foreach ($credit['items'] as $item) { $sub_tpl_component = array(); $sub_tpl_component['INVOICE_ROW_ITEM_NAME'] = $item['item_name']; $sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_HT'] = '-' . number_format($item['item_total_ht'], 2, '.', ''); $sub_tpl_component['INVOICE_ROW_ITEM_TVA_TOTAL_AMOUNT'] = '-' . number_format($item['item_tva_total_amount'], 2, '.', '') . ' (' . $item['item_tva_rate'] . '%)'; $sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_TTC'] = '-' . number_format($item['item_total_ttc'], 2, '.', ''); $total_HT += $item['item_total_ht']; $total_TTC += $item['item_total_ttc']; if (empty($credit_TVA[(string) $item['item_tva_rate']])) { $credit_TVA[$item['item_tva_rate']] = $item['item_tva_total_amount']; } else { $credit_TVA[(string) $item['item_tva_rate']] += $item['item_tva_total_amount']; } $tpl_component['INVOICE_ROWS'] .= wpshop_display::display_template_element('credit_slip_row', $sub_tpl_component, array(), 'common'); unset($sub_tpl_component); } } $d = ''; foreach ($credit_TVA as $tx => $value) { $tva_tpl_component['SUMMARY_ROW_TITLE'] = sprintf(__('Tax amount (%s %s)', 'wpshop'), $tx, '%'); $tva_tpl_component['SUMMARY_ROW_VALUE'] = '-' . number_format($value, '2', '.', '') . ' ' . wpshop_tools::wpshop_get_currency(false); $d .= wpshop_display::display_template_element('invoice_summary_row', $tva_tpl_component, array(), 'common'); unset($tva_tpl_component); } $sub_tpl_component['CREDIT_SLIP_SUMMARY_TVA'] = $d; $sub_tpl_component['INVOICE_SUMMARY_MORE'] = ''; $sub_tpl_component['CREDIT_SLIP_TOTAL_HT'] = '-' . number_format($total_HT, '2', '.', ''); $sub_tpl_component['CREDIT_SLIP_ORDER_GRAND_TOTAL'] = '-' . number_format($total_TTC, '2', '.', ''); $tpl_component['INVOICE_SUMMARY_PART'] = wpshop_display::display_template_element('credit_slip_summary_part', $sub_tpl_component, array(), 'common'); $tpl_component['RECEIVED_PAYMENT'] = ''; $tpl_component['INVOICE_FOOTER'] = wpshop_modules_billing::generate_footer_invoice(); $output = wpshop_display::display_template_element('invoice_page_content', $tpl_component, array(), 'common'); unset($tpl_component); return $output; }
function wpshop_dashboard_orders() { $output = ''; $orders = get_posts(array('posts_per_page' => 10, 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'post_status' => 'publish', 'orderby' => 'post_date', 'order' => 'DESC')); if (!empty($orders)) { $payment_status = unserialize(WPSHOP_ORDER_STATUS); $output .= '<table id="wps_dashboard_orders_summary">'; $output .= '<tr><th class="wps_dashboard_order_date">' . __('Date', 'wpshop') . '</th><th class="wps_dashboard_order_customer_name">' . __('Customer', 'wpshop') . '</th><th class="wps_dashboard_order_amount">' . __('Amount', 'wpshop') . '</th><th class="wps_dashboard_order_status">' . __('Status', 'wpshop') . '</th><th class="wps_dashboard_order_actions"></th></tr>'; $stried = false; foreach ($orders as $order) { $stried = $stried == false ? true : false; $additionnal_class = $stried ? 'wps_stried_line' : ''; $output .= '<tr class="' . $additionnal_class . '">'; $order_meta = get_post_meta($order->ID, '_order_postmeta', true); $order_info = get_post_meta($order->ID, '_order_info', true); if (!empty($order_meta)) { $output .= '<td>' . (!empty($order_meta) && !empty($order_meta['order_date']) ? date('d-m-Y', strtotime($order_meta['order_date'])) : '') . '</td>'; $output .= '<td>' . (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_last_name']) && !empty($order_info['billing']['address']['address_first_name']) ? strtoupper($order_info['billing']['address']['address_last_name']) . ' ' . $order_info['billing']['address']['address_first_name'] : '') . '</td>'; $output .= '<td>' . (!empty($order_meta['order_grand_total']) ? number_format($order_meta['order_grand_total'], 2, '.', '') . ' ' . wpshop_tools::wpshop_get_currency(false) : '-') . '</td>'; $output .= '<td><span class="wps_dashboard_' . $order_meta['order_status'] . '">' . __($payment_status[$order_meta['order_status']], 'wpshop') . '</span></td>'; $output .= '<td>'; $output .= '<a href="' . admin_url('/post.php?post=' . $order->ID . '&action=edit') . '"><img src="' . WPSHOP_MEDIAS_ICON_URL . 'icon_loupe.png" alt="' . __('See', 'wpshop') . '" /></a>'; $invoice_ref = ''; if (!empty($order_meta['order_invoice_ref'])) { $invoice_ref = $order_meta['order_invoice_ref']; } if (!empty($invoice_ref)) { if (!empty($order_meta) && !empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['received'])) { $invoice_ref = $order_meta['order_payment']['received'][count($order_meta['order_payment']['received']) - 1]['invoice_ref']; } } if (($order_meta['order_status'] == 'partially_paid' || $order_meta['order_status'] == 'completed' || $order_meta['order_status'] == 'shipped') && !empty($invoice_ref)) { $output .= ' <a href="' . WPSHOP_TEMPLATES_URL . 'invoice.php?order_id=' . $order->ID . '&invoice_ref&=' . $invoice_ref . '&mode=pdf"><img src="' . WPSHOP_MEDIAS_ICON_URL . 'icon_invoice.png" alt="' . __('Invoice', 'wpshop') . '" /></a>'; } if ($order_meta['order_status'] == 'shipped') { $output .= ' <a href="' . WPSHOP_TEMPLATES_URL . 'invoice.php?order_id=' . $order->ID . '&bon_colisage=ok&mode=pdf"><img src="' . WPSHOP_MEDIAS_ICON_URL . 'bon_colisage_icon.png" alt="' . __('Shipping Slip', 'wpshop') . '" /></a>'; } $output .= '</td>'; } $output .= '</tr>'; } $output .= '</table>'; } return $output; }
public static function process_checkout($paymentMethod = 'paypal', $order_id = 0, $customer_id = 0, $customer_billing_address_id = 0, $customer_shipping_address_id = 0) { global $wpdb, $wpshop, $wpshop_cart; $wps_message = new wps_message_ctr(); $shipping_address_option = get_option('wpshop_shipping_address_choice'); if (is_user_logged_in()) { $user_id = get_current_user_id(); if ($customer_id != 0) { $user_id = $customer_id; } // If the order is already created in the db if (!empty($order_id) && is_numeric($order_id)) { $order = get_post_meta($order_id, '_order_postmeta', true); if (!empty($order)) { if ($order['customer_id'] == $user_id) { $order['payment_method'] = $paymentMethod; $_SESSION['order_id'] = wpshop_tools::varSanitizer($order_id); // Store cart in session //wpshop_cart::store_cart_in_session($order); // Add a payment $order['order_payment']['received'][] = array('method' => $paymentMethod, 'waited_amount' => $order['order_amount_to_pay_now'], 'status' => 'waiting_payment', 'author' => get_current_user_id()); // On enregistre la commande update_post_meta($order_id, '_order_postmeta', $order); update_post_meta($order_id, '_wpshop_order_customer_id', $user_id); } else { $wpshop->add_error(__('You don\'t own the order', 'wpshop')); } } else { $wpshop->add_error(__('The order doesn\'t exist.', 'wpshop')); } } else { $order_data = array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'post_title' => sprintf(__('Order - %s', 'wpshop'), mysql2date('d M Y\\, H:i:s', current_time('mysql', 0), true)), 'post_status' => 'publish', 'post_excerpt' => !empty($_POST['wps-customer-comment']) ? $_POST['wps-customer-comment'] : '', 'post_author' => $user_id, 'comment_status' => 'closed'); // Cart items $order_items = array(); $order_tva = array(); //$cart = (array)$wpshop_cart->cart; if (!empty($_SESSION['cart']) && !empty($_SESSION['cart']['shipping_method'])) { $_SESSION['cart']['shipping_method'] = __('Standard shipping method', 'wpshop'); } $cart = (array) $_SESSION['cart']; $download_codes = array(); // Nouvelle commande $order_id = wp_insert_post($order_data); $_SESSION['order_id'] = $order_id; // Cr�ation des codes de t�l�chargement si il y a des produits t�l�chargeable dans le panier if (!empty($cart['order_items'])) { foreach ($cart['order_items'] as $c) { $product = wpshop_products::get_product_data($c['item_id']); /** Check if it's a variation and check the parent product **/ if (get_post_type($c['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) { $parent_def = wpshop_products::get_parent_variation($c['item_id']); if (!empty($parent_def) && !empty($parent_def['parent_post_meta']) && !empty($parent_def['parent_post_meta']['is_downloadable_'])) { $product['is_downloadable_'] = $parent_def['parent_post_meta']['is_downloadable_']; } } if (!empty($product['is_downloadable_'])) { $download_codes[$c['item_id']] = array('item_id' => $c['item_id'], 'download_code' => uniqid('', true)); } } } if (!empty($download_codes)) { update_user_meta($user_id, '_order_download_codes_' . $order_id, $download_codes); } // Informations de commande � stocker $currency = wpshop_tools::wpshop_get_currency(true); $order = array_merge(array('order_key' => NULL, 'customer_id' => $user_id, 'order_status' => 'awaiting_payment', 'order_date' => current_time('mysql', 0), 'order_shipping_date' => null, 'order_invoice_ref' => '', 'order_currency' => $currency, 'order_payment' => array('customer_choice' => array('method' => $paymentMethod), 'received' => array('0' => array('method' => $paymentMethod, 'waited_amount' => $cart['order_amount_to_pay_now'], 'status' => 'waiting_payment', 'author' => $user_id)), 'shipping_method' => !empty($_SESSION['shipping_method']) ? wpshop_tools::varSanitizer($_SESSION['shipping_method']) : __('Standard shipping method', 'wpshop'))), $cart); // Si c'est un devis if ($paymentMethod == 'quotation') { $order['order_temporary_key'] = wpshop_orders::get_new_pre_order_reference(); } else { $order['order_key'] = wpshop_orders::get_new_order_reference(); } //Round final amount $order['order_grand_total'] = number_format(round($order['order_grand_total'], 2), 2, '.', ''); $order['order_total_ttc'] = number_format(round($order['order_total_ttc'], 2), 2, '.', ''); $order['order_amount_to_pay_now'] = number_format(round($order['order_amount_to_pay_now'], 2), 2, '.', ''); /** On enregistre la commande */ update_post_meta($order_id, '_order_postmeta', $order); update_post_meta($order_id, '_wpshop_order_customer_id', $order['customer_id']); update_post_meta($order_id, '_wpshop_order_shipping_date', $order['order_shipping_date']); update_post_meta($order_id, '_wpshop_order_status', $order['order_status']); do_action('wps_order_extra_save', $order_id); //Add an action to extra actions on order save $args = array('order_id' => $order_id, 'posted_data' => $_REQUEST); wpshop_tools::create_custom_hook('wps_order_extra_save_action', $args); /** Set custmer information for the order */ $shipping_address = !empty($shipping_address_option) && !empty($shipping_address_option['activate']) ? !empty($_SESSION['shipping_address']) ? wpshop_tools::varSanitizer($_SESSION['shipping_address']) : $customer_shipping_address_id : ''; $billing_address = !empty($_SESSION['billing_address']) ? wpshop_tools::varSanitizer($_SESSION['billing_address']) : $customer_billing_address_id; if (!empty($billing_address)) { wpshop_orders::set_order_customer_addresses($user_id, $order_id, $shipping_address, $billing_address); } if (!empty($_SESSION['shipping_address_to_save'])) { $order_infos_postmeta = get_post_meta($order_id, '_order_info', true); $order_infos_postmeta['shipping']['address'] = $_SESSION['shipping_address_to_save']; $order_infos_postmeta['shipping']['address_id'] = ''; update_post_meta($order_id, '_order_info', $order_infos_postmeta); unset($_SESSION['shipping_address_to_save']); } /** Save Coupon use **/ if (!empty($_SESSION['cart']['coupon_id'])) { $wps_coupon_mdl = new wps_coupon_model(); $wps_coupon_mdl->save_coupon_use($_SESSION['cart']['coupon_id']); } /** Notify the customer as the case */ $user_info = get_userdata($user_id); $email = $user_info->user_email; $first_name = $user_info->user_firstname; $last_name = $user_info->user_lastname; // Envoie du message de confirmation de commande au client $order_meta = get_post_meta($order_id, '_order_postmeta', true); $shipping_mode_option = get_option('wps_shipping_mode'); $shipping_method = !empty($order_meta['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_meta['order_payment']['shipping_method'], $shipping_mode_option['modes']) ? $shipping_mode_option['modes'][$order_meta['order_payment']['shipping_method']]['name'] : (!empty($order_meta['order_payment']['shipping_method']) ? $order_meta['order_payment']['shipping_method'] : ''); if (!empty($order_meta) && !empty($order_meta['cart_type']) && $order_meta['cart_type'] == 'quotation' && empty($order_meta['order_key'])) { $wps_message->wpshop_prepared_email($email, 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE', array('order_id' => $order_id, 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_date' => current_time('mysql', 0), 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method, 'order_personnal_informations' => '')); } else { $email_option = get_option('wpshop_emails'); if (empty($email_option['send_confirmation_order_message'])) { $payment_method_option = get_option('wps_payment_mode'); $order_payment_method = !empty($payment_method_option) && !empty($payment_method_option['mode']) && !empty($order_meta['order_payment']['customer_choice']['method']) && !empty($payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']]) ? $payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']]['name'] : $order_meta['order_payment']['customer_choice']['method']; $wps_message->wpshop_prepared_email($email, 'WPSHOP_ORDER_CONFIRMATION_MESSAGE', array('order_id' => $order_id, 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_key' => !empty($order_meta['order_key']) ? $order_meta['order_key'] : '', 'order_date' => current_time('mysql', 0), 'order_payment_method' => $order_payment_method, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method, 'order_personnal_informations' => '')); } } if (empty($_SESSION['wps-pos-addon'])) { $email_option = get_option('wpshop_emails'); if (empty($email_option) || !empty($email_option) && empty($email_option['send_confirmation_order_message'])) { self::send_order_email_to_administrator($order_id, $user_info); } } /** IF Order amount is 0, Finish the Order **/ if ($cart['order_amount_to_pay_now'] == 0) { $order_meta = get_post_meta($order_id, '_order_postmeta', true); $payment_status = 'completed'; $params_array = array('method' => 'free', 'waited_amount' => $order_meta['order_amount_to_pay_now'], 'status' => 'payment_received', 'author' => $order_meta['customer_id'], 'payment_reference' => 'FREE_ORDER', 'date' => current_time('mysql', 0), 'received_amount' => $order_meta['order_amount_to_pay_now']); wpshop_payment::check_order_payment_total_amount($order_id, $params_array, $payment_status); } apply_filters('wpshop_finish_order_extra_actions', $order_id); } } return $order_id; }
/** * Affichage des variations d'un produit dans l'administration * * @param integer $head_product L'identifiant du produit dont on veut afficher les variations * @return string Le code html permettant l'affichage des variations dans l'interface d'édition du produit */ public static function display_variation_admin($head_product) { $output = ''; $productCurrency = wpshop_tools::wpshop_get_currency(); /* Récupération de la liste des variations pour le produit en cours d'édition */ $variations = self::get_variation($head_product); $price_piloting = get_option('wpshop_shop_price_piloting'); /* Affichage de la liste des variations pour le produit en cours d'édition */ if (!empty($variations) && is_array($variations)) { $existing_variation_list = wpshop_display::display_template_element('wpshop_admin_existing_variation_controller', array(), array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT => $head_product), 'admin'); foreach ($variations as $variation) { $tpl_component = array(); $tpl_component['ADMIN_EXISTING_VARIATIONS_CLASS'] = ' wpshop_variation_' . self::currentPageCode; $tpl_component['VARIATION_IDENTIFIER'] = $variation['post']->ID; $tpl_component['VARIATION_DETAIL'] = ' '; $p = !empty($variation['variation_dif']['product_price']) || !empty($variation['variation_dif']['price_ht']) ? !empty($price_piloting) && $price_piloting == 'HT' && !empty($variation['variation_dif']['price_ht']) ? $variation['variation_dif']['price_ht'] : !empty($variation['variation_dif']['product_price']) ? $variation['variation_dif']['product_price'] : 0 : 0; $tpl_component['VARIATION_DETAIL_PRICE'] = number_format($p, 2, '.', '') . ' ' . $productCurrency . ' ' . (!empty($price_piloting) && $price_piloting == 'HT' ? __('ET', 'wpshop') : __('ATI', 'wpshop')); if (!empty($price_piloting) && $price_piloting == 'HT') { } else { } $post_obj = $variation['post']; $parent_product_infos = wpshop_products::get_parent_variation($post_obj->ID); if (!empty($parent_product_infos)) { $parent_post = $parent_product_infos['parent_post']; $product_option_postmeta = get_post_meta($parent_post->ID, '_wpshop_variation_defining', true); if (!empty($product_option_postmeta['options']['price_behaviour']) && !empty($product_option_postmeta['options']['price_behaviour'][0]) && $product_option_postmeta['options']['price_behaviour'][0] == 'addition') { if (!empty($price_piloting) && $price_piloting == 'HT') { $product_price = (!empty($variation['variation_dif']['price_ht']) ? $variation['variation_dif']['price_ht'] : 0) + $parent_product_infos['parent_post_meta']['price_ht']; } else { $product_price = (!empty($variation['variation_dif']['product_price']) ? $variation['variation_dif']['product_price'] : 0) + $parent_product_infos['parent_post_meta']['product_price']; } $tpl_component['VARIATION_DETAIL_SALE_PRICE_INDICATION'] = __('Variation price combined with the parent product price', 'wpshop'); } else { if (!empty($price_piloting) && $price_piloting == 'HT') { $product_price = !empty($variation['variation_dif']['price_ht']) ? $variation['variation_dif']['price_ht'] : 0; } else { $product_price = !empty($variation['variation_dif']['product_price']) ? $variation['variation_dif']['product_price'] : 0; } $tpl_component['VARIATION_DETAIL_SALE_PRICE_INDICATION'] = __('Only variation\'s price is used', 'wpshop'); } $product_price = number_format(str_replace(',', '.', $product_price), 2, '.', '') . ' ' . $productCurrency . ' ' . (!empty($price_piloting) && $price_piloting == 'HT' ? __('ET', 'wpshop') : __('ATI', 'wpshop')); $tpl_component['VARIATION_DETAIL_SALE_PRICE'] = $product_price; } if (!empty($variation['variation_def'])) { foreach ($variation['variation_def'] as $variation_key => $variation_value) { if (!empty($variation_value)) { $attribute_def_for_variation = wpshop_attributes::getElement($variation_key, "'valid'", 'code'); $tpl_component['VARIATION_DETAIL'] .= '<input type="hidden" name="' . self::current_page_variation_code . '[' . $variation['post']->ID . '][attribute][' . $attribute_def_for_variation->data_type . '][' . $variation_key . ']" value="' . $variation_value . '" />' . wpshop_display::display_template_element('wpshop_admin_variation_item_def_header', array('VARIATION_ATTRIBUTE_CODE' => $attribute_def_for_variation->frontend_label, 'VARIATION_ATTRIBUTE_CODE_VALUE' => stripslashes(wpshop_attributes::get_attribute_type_select_option_info($variation_value, 'label', $attribute_def_for_variation->data_type_to_use, true))), array(), 'admin'); $tpl_component['VARIATION_IMAGE_CHOICE'] = ''; /** Define Link image to variation interface **/ if (!empty($product_option_postmeta) && !empty($product_option_postmeta['attributes']) && !empty($product_option_postmeta['variation_type']) && (count($product_option_postmeta['attributes']) == 1 && $product_option_postmeta['variation_type'] == 'single' || $product_option_postmeta['variation_type'] == 'combined')) { $pictures = get_posts(array('post_type' => 'attachment', 'posts_per_page' => -1, 'post_status' => null, 'post_parent' => $head_product)); $media_id_data = get_post_meta($head_product, '_wps_product_media', true); if (!empty($media_id_data)) { $medias_ids = explode(',', $media_id_data); if (!empty($medias_ids)) { foreach ($medias_ids as $media_id) { if (!empty($media_id)) { $pictures[] = get_post($media_id); } } } } $pictures_data = ''; if (!empty($pictures)) { $selected_picture = get_post_meta($variation['post']->ID, '_wps_variation_attached_picture', true); $done_picture = array(); foreach ($pictures as $picture) { if (!in_array($picture->ID, $done_picture)) { $checked = !empty($selected_picture) && $selected_picture == $picture->ID ? 'checked="checked"' : ''; $pictures_data .= wpshop_display::display_template_element('wpshop_admin_variation_picture_choice_element', array('PICTURE_CHOICE_VARIATION_ID' => $picture->ID, 'PRODUCT_VARIATION_ID' => $variation['post']->ID, 'PICTURE_CHOICE_SELECTED' => $checked, 'PICTURE_CHOICE_VARIATION_IMG' => wp_get_attachment_image($picture->ID, 'thumbnail')), array(), 'admin'); $done_picture[] = $picture->ID; } } } $tpl_component['VARIATION_IMAGE_CHOICE'] = wpshop_display::display_template_element('wpshop_admin_variation_picture_choice_container', array('PICTURE_CHOICE_CONTAINER_CONTENT' => $pictures_data), array(), 'admin'); } } } } $tpl_component['VARIATION_DETAIL'] = substr($tpl_component['VARIATION_DETAIL'], 0, -2); $tpl_component['ADMIN_VARIATION_SPECIFIC_DEFINITION_CONTAINER_CLASS'] = ' wpshopHide'; $tpl_component['VARIATION_DEFINITION'] = wpshop_attributes::get_variation_attribute(array('input_class' => ' ', 'field_name' => wpshop_products::current_page_variation_code . '[' . $variation['post']->ID . ']', 'page_code' => self::current_page_variation_code, 'field_id' => self::current_page_variation_code . '_' . $variation['post']->ID, 'variation_dif_values' => !empty($variation['variation_dif']) ? $variation['variation_dif'] : array())); $tpl_component['VARIATION_DEFINITION_CONTENT'] = wpshop_display::display_template_element('wpshop_admin_variation_item_specific_def', $tpl_component, array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT => $head_product, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION => $variation['post']->ID), 'admin'); /* Add the variation definition to output */ $existing_variation_list .= wpshop_display::display_template_element('wpshop_admin_variation_item_def', $tpl_component, array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT => $head_product, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION => $variation['post']->ID), 'admin'); } $output .= wpshop_display::display_template_element('wpshop_admin_existing_variation_list', array('ADMIN_EXISTING_VARIATIONS_CONTAINER_CLASS' => '', 'ADMIN_EXISTING_VARIATIONS_CONTAINER' => $existing_variation_list), array(), 'admin'); /* Reset de la liste des résultats pour éviter les comportements indésirables */ wp_reset_query(); } else { $output = __('No variation found for this product. Please use button above for create one', 'wpshop'); } return $output; }
?> " /></td> </tr> <tr class="wpshop_coupon_definition_table_code_type_line" > <td class="wpshop_coupon_definition_table_label wpshop_coupon_definition_coupon_type_amount_label" ><input type="radio" name="coupon_type" class="wpshop_coupon_type" id="coupon_type_amount" value="amount" <?php echo $wpshop_coupon_discount_type == 'amount' || empty($wpshop_coupon_discount_type) ? 'checked="checked"' : null; ?> /><label for="coupon_type_amount" ><?php _e('Coupon discount amount', 'wpshop'); ?> </label></td> <td class="wpshop_coupon_definition_table_input wpshop_coupon_definition_coupon_type_input" rowspan="2" ><input type="text" name="coupon_discount_amount" value="<?php echo $coupon_discount_amount; ?> " /><span class="wpshop_coupon_type_unit wpshop_coupon_type_unit_amount" > <?php echo !empty($wpshop_coupon_discount_type) && $wpshop_coupon_discount_type == 'percent' ? '%' : wpshop_tools::wpshop_get_currency() . ' ' . __('ATI', 'wpshop'); ?> </span><span class="wpshopHide wpshop_coupon_type_unit wpshop_coupon_type_unit_percent" > % </span></td> </tr> <tr class="wpshop_coupon_definition_table_code_type_line" > <td class="wpshop_coupon_definition_table_label wpshop_coupon_definition_coupon_type_percent_label" ><input type="radio" name="coupon_type" id="coupon_type_percent" class="wpshop_coupon_type" value="percent" <?php echo $wpshop_coupon_discount_type == 'percent' ? 'checked="checked"' : null; ?> /><label for="coupon_type_percent" ><?php _e('Coupon discount percent', 'wpshop'); ?> </label></td> </tr> <tr> <td> <label for="coupon_receiver"><?php
foreach ($orders as $order) { $order_meta = get_post_meta($order->ID, '_order_postmeta', true); $order_info = get_post_meta($order->ID, '_order_info', true); if (!empty($order_meta)) { ?> <div class="wps-table-content wps-table-row"> <div class="wps-table-cell"><?php echo !empty($order_meta['order_date']) ? mysql2date('d F Y', $order_meta['order_date'], true) : ''; ?> </div> <div class="wps-table-cell"><?php echo !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_last_name']) && !empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] . ' ' . $order_info['billing']['address']['address_last_name'] : ''; ?> </div> <div class="wps-table-cell"><?php echo !empty($order_meta['order_grand_total']) ? number_format($order_meta['order_grand_total'], 2, '.', '') . ' ' . wpshop_tools::wpshop_get_currency(false) : ''; ?> </div> <div class="wps-table-cell wps_dashboard_<?php echo $order_meta['order_status']; ?> "><?php _e($payment_status[$order_meta['order_status']], 'wpshop'); ?> </div> <div class="wps-table-cell"><a href="<?php echo admin_url('/post.php?post=' . $order->ID . '&action=edit'); ?> " role="button" class="wps-bton-first-mini-rounded"><?php _e('See', 'wpshop'); ?>
)</strong> : </label> <div class="wps-form"><input type="text" name="weight_rule" id="<?php echo $k; ?> _weight_rule" class="shipping_rules_configuration_input"/></div> </div> <div class="wps-form-group"> <label for="<?php echo $k; ?> _shipping_price"><?php _e('Price', 'wpshop'); ?> <strong>(<?php echo wpshop_tools::wpshop_get_currency(); ?> <?php echo WPSHOP_PRODUCT_PRICE_PILOT; ?> )</strong> : </label> <div class="wps-form"><input type="text" name="shipping_price" id="<?php echo $k; ?> _shipping_price" class="shipping_rules_configuration_input"/></div> </div> </div> <div class="wps-row"> <input type="checkbox" id="<?php echo $k;
$partial_payment_informations = $wps_partial_payment_data['for_all']; $partial_payment_amount = $_SESSION['cart']['order_partial_payment']; ?> <p class="wps-hightlight"><?php _e('Total ATI', 'wpshop'); ?> <span class="wps-alignRight"><strong><?php echo wpshop_tools::formate_number($cart_content['order_grand_total']); ?> </strong> <?php echo $currency; ?> </span></p> <p class="wps-hightlight"> <?php printf(__('Payable now %s', 'wpshop'), '(' . $partial_payment_informations['value'] . (!empty($partial_payment_informations['type']) && $partial_payment_informations['type'] == 'percentage' ? '%' : wpshop_tools::wpshop_get_currency(false)) . ')'); ?> <span class="wps-alignRight"><strong><?php echo wpshop_tools::formate_number($partial_payment_amount); ?> </strong> <?php echo $currency; ?> </span></p> <?php } elseif (!empty($cart_content) && !empty($cart_content['order_status']) && 'partially_paid' == $cart_content['order_status'] && !empty($cart_content['order_payment']) && !empty($cart_content['order_payment']['received'])) { ?> <p class="wps-hightlight"><?php _e('Total ATI', 'wpshop'); ?> <span class="wps-alignRight"><strong><?php
/** * Display value for a given attribute * * @param unknown_type $attributeDefinition * @return multitype:Ambigous <unknown, string> Ambigous <string, string> Ambigous <> */ public static function wps_attribute_values_display($attributeDefinition) { $attribute_unit_list = ''; if (!empty($attributeDefinition['unit'])) { /** Template parameters */ $template_part = 'product_attribute_unit'; $tpl_component = array(); $tpl_component['ATTRIBUTE_UNIT'] = $attributeDefinition['unit']; /** Build template */ $attribute_unit_list = wpshop_display::display_template_element($template_part, $tpl_component); unset($tpl_component); } $attribute_value = $attributeDefinition['value']; if ($attributeDefinition['data_type'] == 'decimal') { $attribute_value = is_numeric($attribute_value) ? number_format($attribute_value, 2, ',', '') : $attribute_value; if (in_array($attributeDefinition['code'], unserialize(WPSHOP_ATTRIBUTE_PRICES))) { if ($attributeDefinition['is_requiring_unit'] == 'yes') { $attribute_unit_list = ' ' . wpshop_tools::wpshop_get_currency(); } $attributeDefinition['value'] = wpshop_display::format_field_output('wpshop_product_price', $attributeDefinition['value']); } } if ($attributeDefinition['data_type'] == 'datetime') { $attribute_value = mysql2date('d/m/Y', $attributeDefinition['value'], true); } if ($attributeDefinition['backend_input'] == 'select') { $attribute_value = wpshop_attributes::get_attribute_type_select_option_info($attributeDefinition['value'], 'label', $attributeDefinition['data_type_to_use']); } /** Manage differently if its an array of values or not */ if ($attributeDefinition['backend_input'] == 'multiple-select') { $attribute_value = ''; if (is_array($attributeDefinition['value'])) { foreach ($attributeDefinition['value'] as $v) { $attribute_value .= ' / ' . wpshop_attributes::get_attribute_type_select_option_info($v, 'label', $attributeDefinition['data_type_to_use']); } } else { $attribute_value = ' / ' . wpshop_attributes::get_attribute_type_select_option_info($attributeDefinition['value'], 'label', $attributeDefinition['data_type_to_use']); } $attribute_value = substr($attribute_value, 3); } return array($attribute_value, $attributeDefinition['value'], $attribute_unit_list); }
?> </td> <td style="width: 1%;"></td> </tr> <?php } ?> </table> <table cellspacing="0" style="width: 100%;font-size: 13px;font-weight: bold;border: solid 1px black;"> <tr> <td style="width: 80%;"><?php _e('Bank deposit sum', 'wpshop'); ?> </td> <td style="width: 19%;text-align: right;"><?php echo number_format($_POST['amount'], 2, '.', '') . wpshop_tools::wpshop_get_currency(); ?> </td> <td style="width: 1%;"></td> </tr> </table> <?php $content = ob_get_contents(); ob_end_clean(); if (!empty($_GET['mode']) && $_GET['mode'] == 'pdf') { require_once WPSHOP_LIBRAIRIES_DIR . 'HTML2PDF/html2pdf.class.php'; try { $html_content = '<page>' . $content . '</page>'; $html2pdf = new HTML2PDF('P', 'A4', 'fr'); $html2pdf->setDefaultFont('Arial'); $html2pdf->writeHTML($html_content);