wpsc_admin_ajax

WP eCommerce Admin AJAX functions.

Description

wpsc_admin_ajax(); 

These are the WPSC Admin AJAX functions


Usage

  1. if ( !function_exists( 'wpsc_admin_ajax' ) ) { 
  2. require_once '/wpsc-admin/ajax-and-init.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wpsc_admin_ajax(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wpsc-admin/ajax-and-init.php  
  1. function wpsc_admin_ajax() { 
  2.  
  3. if ( ! wpsc_is_store_admin() ) { 
  4. return; 
  5.  
  6. global $wpdb; 
  7.  
  8. if ( isset( $_POST['action'] ) && $_POST['action'] == 'product-page-order' ) { 
  9. $current_order = get_option( 'wpsc_product_page_order' ); 
  10. $new_order = $_POST['order']; 
  11.  
  12. if ( isset( $new_order["advanced"] ) ) { 
  13. $current_order["advanced"] = array_unique( explode( ', ', $new_order["advanced"] ) ); 
  14. if ( isset( $new_order["side"] ) ) { 
  15. $current_order["side"] = array_unique( explode( ', ', $new_order["side"] ) ); 
  16.  
  17. update_option( 'wpsc_product_page_order', $current_order ); 
  18. exit( print_r( $order, 1 ) ); 
  19.  
  20.  
  21. if ( isset( $_POST['save_image_upload_state'] ) && $_POST['save_image_upload_state'] == 'true' && is_numeric( $_POST['image_upload_state'] ) ) { 
  22. $upload_state = (int)(bool)$_POST['image_upload_state']; 
  23. update_option( 'wpsc_use_flash_uploader', $upload_state ); 
  24. exit( "done" ); 
  25.  
  26. if ( isset( $_POST['remove_variation_value'] ) && $_POST['remove_variation_value'] == "true" && is_numeric( $_POST['variation_value_id'] ) ) { 
  27. $value_id = absint( $_GET['variation_value_id'] ); 
  28. echo wp_delete_term( $value_id, 'wpsc-variation' ); 
  29. exit(); 
  30.  
  31. if ( isset( $_REQUEST['log_state'] ) && $_REQUEST['log_state'] == "true" && is_numeric( $_POST['id'] ) && is_numeric( $_POST['value'] ) ) { 
  32. $newvalue = $_POST['value']; 
  33. if ( $_REQUEST['suspend'] == 'true' ) { 
  34. if ( $_REQUEST['value'] == 1 && function_exists('wpsc_member_dedeactivate_subscriptions')) 
  35. wpsc_member_dedeactivate_subscriptions( $_POST['id'] ); 
  36. elseif( function_exists('wpsc_member_deactivate_subscriptions')) 
  37. wpsc_member_deactivate_subscriptions( $_POST['id'] ); 
  38.  
  39. exit(); 
  40. } else { 
  41.  
  42. $log_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id` = '%d' LIMIT 1", $_POST['id'] ), ARRAY_A ); 
  43. if ( ($newvalue == 2) && function_exists( 'wpsc_member_activate_subscriptions' ) ) { 
  44. wpsc_member_activate_subscriptions( $_POST['id'] ); 
  45.  
  46. wpsc_update_purchase_log_status( $_POST['id'], $newvalue ); 
  47.  
  48. if ( ($newvalue > $log_data['processed']) && ($log_data['processed'] < 2) ) { 
  49. transaction_results( $log_data['sessionid'], false ); 
  50.  
  51. $status_name = wpsc_find_purchlog_status_name( $purchase['processed'] ); 
  52. echo "document.getElementById(\"form_group_" . absint( $_POST['id'] ) . "_text\").innerHTML = '" . $status_name . "';\n"; 
  53.  
  54.  
  55. $year = date( "Y" ); 
  56. $month = date( "m" ); 
  57. $start_timestamp = mktime( 0, 0, 0, $month, 1, $year ); 
  58. $end_timestamp = mktime( 0, 0, 0, ($month + 1 ), 0, $year ); 
  59.  
  60. echo "document.getElementById(\"log_total_month\").innerHTML = '" . addslashes( wpsc_currency_display( admin_display_total_price( $start_timestamp, $end_timestamp ) ) ) . "';\n"; 
  61. echo "document.getElementById(\"log_total_absolute\").innerHTML = '" . addslashes( wpsc_currency_display( admin_display_total_price() ) ) . "';\n"; 
  62. exit();