public static function get_instance() { if (self::$instance === null) { self::$instance = new QHShopSession(); } return self::$instance; }
public static function run() { $instance = self::get_instance(); //start session QHShopSession::run(); //start qhshop proudct QHShopProduct::run(); //start shortcode QHShopShortCode::run(); //start setting QHShopSetting::run(); //run widget cart QHShopWidgetCart::run(); //khoi dong order QHShopOrder::run(); //run widget category QHShopWidgetCategory::run(); return $instance; }
public static function save_order() { if (isset($_POST['checkout'])) { $cart = QHShopSession::get('cart'); if ($cart) { $post_id = wp_insert_post(array('post_status' => 'private', 'post_type' => 'product_order', 'post_title' => ' ;', 'post_content' => ' ', 'post_excerpt' => ' '), true); update_post_meta($post_id, 'order', array('checkout' => $_POST['checkout'], 'cart' => $cart, 'status' => 0)); QHShopSession::destroy('cart'); wp_redirect(get_permalink(get_page_by_path('shop'))); } } }
public static function delete_cart_ajax() { $json['status'] = 0; if (isset($_POST['item_id']) && !empty($_POST['item_id'])) { $cart = QHShopSession::get('cart'); $option = get_option('qhshop_setting'); if (!empty($cart)) { QHShopSession::destroy($_POST['item_id']); $total = 0; foreach ($cart as $item) { $total += $item['item_quantity'] * $item['item_price']; } $json['subtotal'] = QHShopTool::get_currency($total, $option); $json['status'] = 1; } } wp_send_json_success($json); }