コード例 #1
0
 /**
  * META-BOX CONTENT - Display customer's order list in customer back-office interface
  */
 function wps_customer_orders_list()
 {
     global $post;
     $output = '';
     $wps_orders = new wps_orders_ctr();
     $output = $wps_orders->display_orders_in_account($post->post_author);
     echo $output;
 }
コード例 #2
0
 /**
  * Add automaticaly products to cart if option is defined
  * @param array $cart_items
  * @return array
  */
 function add_automaticaly_product_to_cart($cart_items)
 {
     global $wpdb;
     // Recovery all products with options
     $query = $wpdb->prepare("SELECT post_id, meta_value FROM " . $wpdb->postmeta . " WHERE meta_key = %s ", '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_options');
     $post_list_with_options = $wpdb->get_results($query);
     $wps_orders = new wps_orders_ctr();
     if (!empty($post_list_with_options) && !empty($cart_items)) {
         foreach ($post_list_with_options as $product_info) {
             $product_meta = unserialize($product_info->meta_value);
             if (!empty($product_meta['cart']) && !empty($product_meta['cart']['auto_add']) && $product_meta['cart']['auto_add'] == 'yes' && empty($cart_items[$product_info->post_id])) {
                 $product = wpshop_products::get_product_data($product_info->post_id, true, '"draft", "publish"');
                 $the_product = array_merge(array('product_id' => $product_info->post_id, 'product_qty' => 1), $product);
                 $cart_items[$product_info->post_id] = $wps_orders->add_product_to_order($the_product);
             }
         }
     }
     return $cart_items;
 }