예제 #1
0
/**
 * Conditionally empties the cart based on the status of `processed`.
 * Removed from being hardcoded in transaction_results().
 *
 * @since  3.9.0
 *
 * @param  WPSC_Purchase_Log $log Purchase Log.
 * @return void
 */
function wpsc_maybe_empty_cart($log)
{
    if ($log->is_transaction_completed() || $log->is_order_received()) {
        global $wpsc_cart;
        $wpsc_cart->empty_cart();
    }
}
예제 #2
0
function wpsc_send_customer_email($purchase_log)
{
    if (!is_object($purchase_log)) {
        $purchase_log = new WPSC_Purchase_Log($purchase_log);
    }
    if (!$purchase_log->is_transaction_completed() && !$purchase_log->is_order_received()) {
        return;
    }
    $email = new WPSC_Purchase_Log_Customer_Notification($purchase_log);
    $email_sent = $email->send();
    do_action('wpsc_transaction_send_email_to_customer', $email, $email_sent);
    return $email_sent;
}
예제 #3
0
 /**
  * Pushes sales data back to Baikonur
  *
  * Only pushes once.  Accounts for annoying potential edge case of status-switching admins
  *
  * @param  WPSC_Purchase_Log object $purchase_log Purchase Log object
  * @return void
  */
 public static function push_sales_data($purchase_log_id, $current_status, $old_status, $purchase_log)
 {
     $purchase_log = new WPSC_Purchase_Log($purchase_log_id);
     $id = absint($purchase_log->get('id'));
     //Also checking is_order_received, as that's what Manual Payments do.
     if ($purchase_log->is_transaction_completed() || $purchase_log->is_order_received()) {
         $pushed_to_sass = wpsc_get_meta($id, '_pushed_to_wpeconomy', 'purchase_log');
         if (empty($pushed_to_saas)) {
             $data = $purchase_log->get_data();
             $cart_contents = $purchase_log->get_cart_contents();
             //We want to push sales data - but naturally, IDs will differ, even names could potentially.
             //So we add the slug to the object we POST
             foreach ($cart_contents as $key => $cart_item) {
                 $slug = get_post_field('post_name', $cart_item->prodid);
                 $cart_contents[$key]->slug = $slug;
             }
             $args = array('body' => array('data' => json_encode($data), 'cart_contents' => json_encode($cart_contents)));
             $request = wp_remote_post('http://www.wpeconomy.org/?sales_data=true', $args);
             $response = wp_remote_retrieve_response_code($request);
             //For some reason, if the site is down, we want the ability to ensure we can grab the sale later.
             $success = 200 === $response;
             wpsc_update_meta($id, '_pushed_to_wpeconomy', $success, 'purchase_log');
         }
     }
 }
function wpsc_get_transaction_html_output($purchase_log)
{
    if (!is_object($purchase_log)) {
        $purchase_log = new WPSC_Purchase_Log($purchase_log);
    }
    if (!$purchase_log->is_transaction_completed() && !$purchase_log->is_order_received()) {
        return '';
    }
    $notification = new WPSC_Purchase_Log_Customer_HTML_Notification($purchase_log);
    $output = $notification->get_html_message();
    $output = apply_filters('wpsc_get_transaction_html_output', $output, $notification);
    return $output;
}
예제 #5
0
 /**
  * Adds product properties to analytics.track() when the order is completed successfully.
  *
  * @since  1.0.0
  * @access public
  *
  * @uses  func_get_args() Because our abstract class doesn't know how many parameters are passed to each hook
  *                        for each different platform, we use func_get_args().
  *
  * @return array Filtered array of name and properties for analytics.track().
  */
 public function completed_order()
 {
     $args = func_get_args();
     $track = $args[0];
     if (did_action('wpsc_transaction_results_shutdown') && isset($_GET['sessionid'])) {
         $log = new WPSC_Purchase_Log($_GET['sessionid'], 'sessionid');
         /* We like checking is_order_received(), as that's what the manual payment gateway uses. */
         if ($log->is_transaction_completed() || $log->is_order_received()) {
             $gateway_data = $log->get_gateway_data();
             $items = $log->get_cart_contents();
             $products = array();
             foreach ($items as $item) {
                 $product = array('id' => $item->prodid, 'sku' => wpsc_product_sku($item->prodid), 'name' => $item->name, 'price' => $item->price, 'quantity' => $item->quantity, 'category' => implode(', ', wp_list_pluck(wpsc_get_product_terms($item->prodid, 'wpsc_product_category'), 'name')));
                 $products[] = $product;
             }
             $track = array('event' => __('Completed Order', 'segment'), 'properties' => array('id' => $log->get('id'), 'total' => $log->get('totalprice'), 'revenue' => $gateway_data['subtotal'], 'shipping' => $gateway_data['shipping'], 'tax' => $gateway_data['tax'], 'products' => $products));
         }
     }
     return $track;
 }