Exemplo n.º 1
0
 public function av8_manage_cart_columns($column, $post_id = '')
 {
     global $post;
     $cart = new AV8_Cart_Receipt();
     $cart->load_receipt($post->ID);
     $cart->set_guest_details();
     $title = '';
     switch ($column) {
         /* If displaying the 'duration' column. */
         case 'cartname':
             $suffix = "'s Cart";
             if ($cart->is_guest_order() && $cart->has_guest_details()) {
                 $fullname = ucwords($cart->get_guest_details('billing_first_name')) . ' ' . ucwords($cart->get_guest_details('billing_last_name'));
                 if ($fullname != ' ') {
                     $title .= $fullname;
                 } else {
                     $title .= "Guest";
                 }
                 $title .= $suffix . " (Guest)";
             } elseif ($cart->is_guest_order() && $cart->status() == "Converted" && isset($cart->order)) {
                 $title = ucwords($cart->order->billing_first_name) . ' ' . ucwords($cart->order->billing_last_name) . $suffix . " (Guest)";
             } elseif ($cart->is_guest_order()) {
                 $title = "Guest" . $suffix;
             } elseif ($cart->full_name() != false) {
                 $title = ucwords($cart->full_name()) . $suffix;
             }
             $post_url = admin_url('post.php?post=' . $post->ID . '&action=edit');
             echo __("<a href='{$post_url}'>" . $title . "</a>");
             break;
         case 'post__in':
             /* Get the post meta. */
             $show_custom_state = $cart->status();
             $filter_link = admin_url('edit.php?post_type=carts&status=' . $show_custom_state);
             echo __('<div class="index_status"><mark class="' . strtolower($show_custom_state) . '_index">' . $show_custom_state . '</mark></div>');
             break;
             /* If displaying the 'genre' column. */
         /* If displaying the 'genre' column. */
         case 'updated':
             /* Get the genres for the post. */
             the_modified_date('F j, Y');
             echo " at ";
             the_modified_date('g:i a');
             break;
             /* Just break out of the switch statement for everything else. */
         /* Just break out of the switch statement for everything else. */
         case 'products':
             //$products = $this->extract_cart_products();
             global $woocommerce;
             $cartitems = get_post_meta($post->ID, 'av8_cartitems', true);
             $items_arr = str_replace(array('O:17:"WC_Product_Simple"', 'O:10:"WC_Product"'), 'O:8:"stdClass"', $cartitems);
             if (isset($cartitems) && $cartitems != false) {
                 $order_items = (array) maybe_unserialize($items_arr);
             } else {
                 break;
             }
             $loop = 0;
             if (sizeof($order_items) > 0 && $order_items != false) {
                 foreach ($order_items as $item) {
                     if (function_exists('get_product')) {
                         if (isset($item['variation_id']) && $item['variation_id'] > 0) {
                             $_product = get_product($item['variation_id']);
                         } else {
                             $_product = get_product($item['product_id']);
                         }
                     } else {
                         if (isset($item['variation_id']) && $item['variation_id'] > 0) {
                             $_product = new WC_Product_Variation($item['variation_id']);
                         } else {
                             $_product = new WC_Product($item['product_id']);
                         }
                     }
                     if (isset($_product) && $_product != false) {
                         echo "<a href='" . get_admin_url('', 'post.php?post=' . $_product->id . '&action=edit') . "'>" . $_product->get_title() . "</a>";
                         if (isset($_product->variation_data)) {
                             echo ' (' . woocommerce_get_formatted_variation($_product->variation_data, true) . ')';
                         }
                         if ($item['quantity'] > 1) {
                             echo " x" . $item['quantity'];
                         }
                     }
                     if ($loop < sizeof($order_items) - 1) {
                         echo ", ";
                     }
                     $loop++;
                 }
             } else {
                 echo "<span style='color:lightgray;'>" . __("No Products", "woocommerce_cart_reports") . "</span>";
             }
             break;
         case 'actions':
             $cart->print_cart_actions($cart->status(), $cart->is_guest_order());
             break;
         default:
             break;
     }
 }
 /**
  *
  * Save the order id of the newly created order in the post meta of the cart object
  */
 public function save_order_id($order_id)
 {
     if (function_exists('get_product')) {
         $session = COOKIEVALUE;
     } else {
         $session = session_id();
     }
     if (WP_DEBUG == true) {
         assert($order_id > 0);
     }
     //$customer_id = get_post_meta($order_id, '_customer_user', true);
     if (!is_restricted_role()) {
         $receipt = new AV8_Cart_Receipt($session);
         $id = $receipt->get_id_from_session($session);
         $receipt->save_conversion();
         global $woocommerce;
         //We need the woo object to get billing info to replace the name fields for Guest Checkouts
         $receipt->save_order_id($order_id, $woocommerce);
     }
 }
Exemplo n.º 3
0
 public function print_cart_actions()
 {
     global $post;
     global $user_info;
     $cart_receipt = new AV8_Cart_Receipt();
     $cart_receipt->load_receipt($post->ID);
     $actions = array();
     $status = $cart_receipt->status();
     switch ($status) {
         case 'Converted':
             //Click to see created order form
             $order_id = '';
             $order_id = get_post_meta($post->ID, 'av8_order_id', true);
             if ($order_id > 0 && $order_id != '') {
                 $order_post = get_post($order_id);
                 $order_link = get_admin_url('', 'post.php?post=' . $order_id . '&action=edit');
                 $actions[] = new AV8_Cart_Action($order_link, 'View Order');
             }
             do_action("av8_carts_action_converted", $actions);
             break;
         case 'Open':
             //Make sure this isn't a guest-owned cart
             if (isset($cart_receipt) && $cart_receipt->full_name() != '') {
                 $full_name = $cart_receipt->full_name();
             } else {
                 $full_name = $cart_receipt->email();
             }
             if ($cart_receipt->email() != false && $cart_receipt->email() != '') {
                 $email_link = "mailto:" . $cart_receipt->email();
                 $actions[] = new AV8_Cart_Action($email_link, "Email {$full_name}");
             }
             do_action("av8_carts_action_open", $actions);
             break;
         case 'Abandoned':
             //Allow the site admin to email the cart abandoner
             //Make sure this isn't a guest-owned cart
             if ($cart_receipt->full_name() != '' && $cart_receipt->full_name() != false) {
                 $full_name = $cart_receipt->full_name();
             } else {
                 $full_name = $cart_receipt->email();
             }
             if ($cart_receipt->email() != false && $cart_receipt->email() != '') {
                 $email_link = "mailto:" . $cart_receipt->email();
                 $actions[] = new AV8_Cart_Action($email_link, "Email {$full_name}");
             }
             do_action("av8_carts_action_abandoned");
             break;
         default:
             break;
     }
     if (empty($actions)) {
         echo "<span style='color:lightgray;'>" . __("No Actions Available", "woocommerce_cart_reports") . "</span>";
     } else {
         //Print the actions
         foreach ($actions as $action) {
             echo $action->display();
         }
     }
 }