function foxyshop_google_products_page() { global $foxyshop_settings, $product; $local_products = array(); $google_icon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAABh0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzT7MfTgAAABZ0RVh0Q3JlYXRpb24gVGltZQAwNy8xNS8xMMjfMS0AAAQRdEVYdFhNTDpjb20uYWRvYmUueG1wADw/eHBhY2tldCBiZWdpbj0iICAgIiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+Cjx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDQuMS1jMDM0IDQ2LjI3Mjk3NiwgU2F0IEphbiAyNyAyMDA3IDIyOjM3OjM3ICAgICAgICAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczp4YXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iPgogICAgICAgICA8eGFwOkNyZWF0b3JUb29sPkFkb2JlIEZpcmV3b3JrcyBDUzM8L3hhcDpDcmVhdG9yVG9vbD4KICAgICAgICAgPHhhcDpDcmVhdGVEYXRlPjIwMTAtMDctMTVUMTk6MDU6MDFaPC94YXA6Q3JlYXRlRGF0ZT4KICAgICAgICAgPHhhcDpNb2RpZnlEYXRlPjIwMTAtMDctMTVUMTk6MTg6MDBaPC94YXA6TW9kaWZ5RGF0ZT4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgICAgIDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiCiAgICAgICAgICAgIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyI+CiAgICAgICAgIDxkYzpmb3JtYXQ+aW1hZ2UvcG5nPC9kYzpmb3JtYXQ+CiAgICAgIDwvcmRmOkRlc2NyaXB0aW9uPgogICA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDBS8igAAAJlSURBVDiNfY9PSFRhFMV/33uvcRzfzKijmQr5jyzFciGFldlGiRCCoAIhqFy0CdpE0Sao3Ei1CtdBuAjDhdBSQiw3SaM5IBpkJTlRaprydJznvO+2sNRJ68CBy733nHuuisfjLVNf4k+fReciI1+TWCa0HLA5VhIAwHOcBR48sMyVlSC/IUohhhHLTCTOWfPz80+GZndFuqdCaAxYg/GYoqd2L1UFGQA50tCwRGfnHz3aMHBs+9DP7OxuKxAI7P64Ksx5gqDWNzx49CZJ75Wi9Yv19SF97x5bEwQcB0+pWsu2bUIBF9GarXg37WwKEgm0UmlzXzJJ1vKyYZimSWNFELSXRncttRl5eJj56hKGT1cxfLqKlXAmIoLyPCyA5v1hmitt+t4vbogayrI36ktHRni+bxpPvPXGBQiuMna7z3LNoqard+srcjlTk8v3pSSLiRSNFUEenysn5DfpmuyifeIhIpL2gmuxe7TMX6jybg7KxeOlXD+RT1mub3NBu7S/a6cj1rF5+S9E1iKovBsD8kNnbTT7r1VysiJIa38r3Z+6dxRuGKQiGOgUWzk05eBql5qcGsJWGDT/pSq79VLOHy3nVHUO4UyT4rCPPaH1V+LLcdoG2uib7vtnAhWb/CoHywsBEOcDOB/AXUAVnwXTj6tdml40MfhtcGeDufiE5Cz1IrOv06f+AozqO6isUqKzUQ73HN5u4EUw9HgHMvMKRNKZ+IYeuw+Soi6/DtuyQdhGQ7tLo6Jlu8FvE3E+A+BpL02oRKFEvTWUyOVkyoztaGL4Uf4CojNREmuJNHGGlzHk077WXxkiNLGzmnadAAAAAElFTkSuQmCC"; $debug_querystring = isset($_GET['debug']) ? "&debug=1" : ""; ?> <?php if (!$foxyshop_settings['google_product_auth']) { ?> <div class="wrap"> <div class="icon32" id="icon-tools"><br></div> <h2>Google Products Management - Authentication Required</h2> <table class="widefat" style="margin-top: 14px;"> <thead> <tr> <th><img src="<?php echo $google_icon; ?> " alt="" /><?php _e("Google Authentication Required", 'foxyshop'); ?> </th> </tr> </thead> <tbody> <tr> <td> <p>To view and manage your Google Products you need to log in to your Google Account. Your username and password are not saved withing FoxyShop, but are passed directly to Google for authentication. If authenticated, Google will issue an auth key that will be stored with your store settings. This auth key will expire after two weeks at which point you will need to authenticate again.</p> <form onsubmit="return false;" autocomplete="off" style="display: block; margin-bottom: 10px;"> <div class="foxyshop_field_control"> <label for="Email"><?php echo __('Email'); ?> </label> <input type="text" id="Email" name="Email" value="" /> </div> <div class="foxyshop_field_control"> <label for="Passwd"><?php echo __('Password'); ?> </label> <input type="password" id="Passwd" name="Passwd" value="" /> </div> <div style="clear: both; height: 4px;"></div> <button class="button-primary" id="authnow">Authenticate Now</button> </form> <div id="error" style="color: red; margin-top: 10px; font-weight: bold; display: none;"></div> <script type="text/javascript"> jQuery(document).ready(function($){ $("#authnow").click(function() { var data = { action: 'foxyshop_set_google_auth', security: '<?php echo wp_create_nonce("foxyshop-ajax-set-google-auth"); ?> ', Email: $("#Email").val(), Passwd: $("#Passwd").val() }; $("#error").hide(); $.post(ajaxurl, data, function(response) { if (!response) { $("#error").text("Error: No Response").show(); } else if (response == "Error") { $("#error").text("Error: Login Failed. Please try again.").show(); } else if (response == "Success") { $("#error").hide(); location.reload(); } else { $("#error").text("Error: " + response).show(); } }); }); }); </script> </td> </tr> </tbody> </table> <?php } else { ?> <div class="wrap"> <div class="icon32" id="icon-tools"><br></div> <h2>Google Products Management <a class="<?php if (version_compare(get_bloginfo('version'), '3.2', "<")) { echo "button "; } ?> add-new-h2" href="edit.php?post_type=foxyshop_product&page=foxyshop_google_products_page&foxyshop_google_products_update=1&googleprodlogout=1&_wpnonce=<?php echo wp_create_nonce('gp1'); ?> ">De-Authenticate</a></h2> <?php //Display Confirmations and Errors if (isset($_GET['error'])) { echo '<div class="error"><p><strong>Error!</strong><br /><ul style="margin: 0 10px;">'; $error_list = explode("||", $_GET['error']); foreach ($error_list as $the_error) { if ($the_error) { echo "<li style=\"list-style: disc inside none;\">{$the_error}</li>\n"; } } echo '</ul></p></div>'; } elseif (isset($_GET['success'])) { echo '<div class="updated"><p>' . __('Operation completed successfully.') . '</p></div>'; } //Get All Local Product ID's $args = array('post_type' => 'foxyshop_product', 'post_status' => 'publish', 'numberposts' => "-1", "orderby" => "id", "order" => "ASC", "meta_key" => "_google_product_category", "meta_compare" => "!=", "meta_value" => ""); $product_list = get_posts($args); foreach ($product_list as $single_product) { $local_products[] = $single_product->ID; } //Get Feed $header_array = array("Authorization: GoogleLogin auth=" . $foxyshop_settings['google_product_auth']); $url = "https://content.googleapis.com/content/v1/" . $foxyshop_settings['google_product_merchant_id'] . "/items/products/schema?performance.start=" . date("Y-m-d", strtotime("-30 days")) . "&max-results=250&performance.end=" . date("Y-m-d", strtotime("now")); if (isset($_GET['nextlink'])) { $url = $_GET['nextlink']; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, $header_array); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $response = trim(curl_exec($ch)); $xml = preg_replace("/(<\\/?)(\\w+):([^>]*>)/", "\$1\$2\$3", $response); $xml = simplexml_load_string($xml, NULL, LIBXML_NOCDATA); //Check For Next Link $nextlink = ""; foreach ($xml->link as $link) { $thisone = 0; foreach ($link->attributes() as $a => $b) { if ($a == "rel" && $b == "next") { $thisone = 1; } if ($thisone && $a == "href") { $nextlink = $b; } } } //Token Has Expired, Remove and Restart Authentication if ((string) $xml->BODY->H1 == "Token invalid" || (string) $xml->BODY->H1 == "Token expired") { $foxyshop_settings['google_product_auth'] = ""; update_option("foxyshop_settings", $foxyshop_settings); $local_products = array(); echo '<div class="updated"><p>' . __('Authentication Failed. It appears that your authentication has expired. This happens every two weeks. Please login again.') . '</p></div>'; echo '<p><a href="edit.php?post_type=foxyshop_product&page=foxyshop_google_products_page" class="button">Login Now</a></p>'; } else { ?> <form action="edit.php?post_type=foxyshop_product&page=foxyshop_google_products_page&foxyshop_manage_google_feed=1" method="post"> <table cellpadding="0" cellspacing="0" border="0" class="wp-list-table widefat foxyshop-list-table" id="product_feed_view" style="margin-top: 14px;"> <thead> <tr> <th id="cb" class="manage-column column-cb check-column" scope="col"><input type="checkbox"></th> <th class="column-id"><span><?php _e('ID', 'foxyshop'); ?> </span><span class="sorting-indicator"></span></th> <th><span><?php _e('Name', 'foxyshop'); ?> </span><span class="sorting-indicator"></span></th> <th><span><?php _e('Image', 'foxyshop'); ?> </span><span class="sorting-indicator"></span></th> <th><span><?php _e('Expiration', 'foxyshop'); ?> </span><span class="sorting-indicator"></span></th> <th><span><?php _e('Performance', 'foxyshop'); ?> </span><span class="sorting-indicator"></span></th> </tr> </thead> <tfoot> <tr> <th class="manage-column column-cb check-column" style="" scope="col"><input type="checkbox"></th> <th><?php _e('ID', 'foxyshop'); ?> </th> <th><?php _e('Name', 'foxyshop'); ?> </th> <th><?php _e('Image', 'foxyshop'); ?> </th> <th><?php _e('Expiration', 'foxyshop'); ?> </th> <th><?php _e('Performance', 'foxyshop'); ?> </th> </tr> </tfoot> <tbody> <?php if (count($xml->entry) == 0) { echo '<tr class="no-items"><td colspan="6" class="colspanchange">No entries found.</td></tr>'; } foreach ($xml->entry as $entry) { $expiration_date = (string) $entry->scexpiration_date; $expiration_date = substr($expiration_date, 0, strpos($expiration_date, "T")); $clicks = 0; foreach ($entry->scperformance->scdatapoint as $scdatapoint) { $clicks += $scdatapoint->attributes()->clicks; } $google_product_id = (string) $entry->scid; if (in_array($google_product_id, $local_products)) { $local_products = array_diff($local_products, array($google_product_id)); $unmatched_text = ""; } else { $unmatched_text = "<br /><em>" . __('Unmatched!', 'foxyshop') . "</em>\n"; } echo '<tr>' . "\n"; echo '<th class="check-column" scope="row"><input type="checkbox" value="' . $google_product_id . '" name="post[]"></th>' . "\n"; echo '<td><strong>' . $google_product_id . '</strong>' . $unmatched_text . '</td>' . "\n"; if ($unmatched_text == "") { echo '<td><strong><a href="post.php?post=' . $google_product_id . '&action=edit">' . (string) $entry->title . '</a></strong>'; echo '<div class="row-actions">'; echo '<span><a href="edit.php?foxyshop_manage_google_feed=1&editid=' . $google_product_id . $debug_querystring . '&_wpnonce=' . wp_create_nonce("manage-the-google-feed-settings") . '" class="update_google_product" rel="' . $google_product_id . '">' . __('Renew/Update', 'foxyshop') . '</a> | </span>'; echo '<span class="delete"><a href="edit.php?foxyshop_manage_google_feed=1&deleteid=' . $google_product_id . $debug_querystring . '&_wpnonce=' . wp_create_nonce("manage-the-google-feed-settings") . '" class="delete_google_product" rel="' . $google_product_id . '">' . __('Delete', 'foxyshop') . '</a></span>'; echo '</div>'; echo '</td>' . "\n"; } else { echo '<td><strong><a href="#" onclick="return false;">' . (string) $entry->title . '</a></strong>'; echo '<div class="row-actions">'; echo '<span class="delete"><a href="edit.php?foxyshop_manage_google_feed=1&deleteid=' . $google_product_id . $debug_querystring . '&_wpnonce=' . wp_create_nonce("manage-the-google-feed-settings") . '" class="delete_google_product" rel="' . $google_product_id . '">' . __('Delete', 'foxyshop') . '</a></span>'; echo '</div>'; echo '</td>' . "\n"; } if ((string) $entry->scimage_link) { echo '<td><img src="' . (string) $entry->scimage_link . '" class="productfeedimage" /></td>' . "\n"; } else { echo '<td> </td>' . "\n"; } echo '<td>' . $expiration_date . '</td>' . "\n"; echo '<td>' . $clicks . ' Click' . ($clicks != 1 ? 's' : '') . '</td>' . "\n"; echo '</tr>' . "\n"; } ?> </tbody> </table> <div style="padding-top: 10px;"> <button type="submit" class="button" name="update_checked_google_products" value="1" id="update_checked_google_products">Update/Renew Checked <?php echo FOXYSHOP_PRODUCT_NAME_PLURAL; ?> </button> <button type="submit" class="button" name="delete_checked_google_products" value="1" id="delete_checked_google_products">Delete Checked <?php echo FOXYSHOP_PRODUCT_NAME_PLURAL; ?> </button> <?php if ($nextlink) { echo '<a href="edit.php?post_type=foxyshop_product&page=foxyshop_google_products_page&nextlink=' . urlencode($nextlink) . '" class="button" style="float: right;">Next Page</a>'; } ?> </div> <input type="hidden" name="foxyshop_run_the_xml" value="1" /> <?php wp_nonce_field('manage-the-google-feed-settings'); ?> <?php if (isset($_GET['debug'])) { echo '<input type="hidden" name="debug" value="1" />'; } ?> </form> <?php } //Display All Unmatched Products $meta_query = array('relation' => 'OR', array('key' => '_google_product_category', 'value' => "", 'compare' => '!=')); $args = array('post_type' => 'foxyshop_product', 'post_status' => 'publish', 'numberposts' => "100", "orderby" => "id", "order" => "ASC", "meta_query" => $meta_query); $product_list = get_posts($args); if ($product_list) { ?> <h2 style="padding: 100px 0 0 0;">Available, Unmatched <?php echo FOXYSHOP_PRODUCT_NAME_PLURAL; ?> to Add</h2> <p style="margin: 0;">In order to appear in this list, <?php echo strtolower(FOXYSHOP_PRODUCT_NAME_PLURAL); ?> must have a "Google Product Category" attribute.</p> <form action="edit.php?post_type=foxyshop_product&page=foxyshop_google_products_page&foxyshop_manage_google_feed=1" method="post"> <table cellpadding="0" cellspacing="0" border="0" class="wp-list-table widefat foxyshop-list-table" id="available_product_view" style="margin-top: 14px;"> <thead> <tr> <th id="cb" class="manage-column column-cb check-column" scope="col"><input type="checkbox"></th> <th class="column-id"><span><?php _e('ID'); ?> </span><span class="sorting-indicator"></span></th> <th><span><?php _e('Name', 'foxyshop'); ?> </span><span class="sorting-indicator"></span></th> <th><span><?php _e('Code', 'foxyshop'); ?> </span><span class="sorting-indicator"></span></th> <th><span><?php _e('Image', 'foxyshop'); ?> </span><span class="sorting-indicator"></span></th> <th><span><?php _e('Price', 'foxyshop'); ?> </span><span class="sorting-indicator"></span></th> <th><span><?php _e('Date', 'foxyshop'); ?> </span><span class="sorting-indicator"></span></th> </tr> </thead> <tfoot> <tr> <th class="manage-column column-cb check-column" style="" scope="col"><input type="checkbox"></th> <th><?php _e('ID', 'foxyshop'); ?> </th> <th><?php _e('Name', 'foxyshop'); ?> </th> <th><?php _e('Code', 'foxyshop'); ?> </th> <th><?php _e('Image', 'foxyshop'); ?> </th> <th><?php _e('Price', 'foxyshop'); ?> </th> <th><?php _e('Data', 'foxyshop'); ?> </th> </tr> </tfoot> <tbody> <?php $none_available = 1; foreach ($product_list as $single_product) { $product = foxyshop_setup_product($single_product); $google_product_listed = (int) get_post_meta($product['id'], '_google_product_listed', TRUE); if ($google_product_listed > strtotime("now") && !isset($_GET['debug'])) { continue; } $none_available = 0; if (!isset($google_product_id)) { $google_product_id = ""; } $salestartdate = get_post_meta($product['id'], '_salestartdate', TRUE); $saleenddate = get_post_meta($product['id'], '_saleenddate', TRUE); if ($salestartdate == '999999999999999999') { $salestartdate = 0; } if ($saleenddate == '999999999999999999') { $saleenddate = 0; } $originalprice = $product['originalprice']; $saleprice = get_post_meta($product['id'], '_saleprice', true); if ($saleprice > 0) { $beginningOK = strtotime("now") > $salestartdate; $endingOK = strtotime("now") < $saleenddate + 86400 || $saleenddate == 0; if ($beginningOK && $endingOK || $salestartdate == 0 && $saleenddate == 0) { $pricewrite = '<span style="text-decoration: line-through; margin-right: 10px;">' . foxyshop_currency($originalprice) . '</span><span style="color: red;">' . foxyshop_currency($saleprice) . '</span>'; } else { $pricewrite = foxyshop_currency($originalprice); } } else { $pricewrite = foxyshop_currency($originalprice); } echo '<tr>' . "\n"; echo '<th class="check-column" scope="row"><input type="checkbox" value="' . $product['id'] . '" name="post[]"></th>' . "\n"; echo '<td><strong>' . $product['id'] . '</strong></td>' . "\n"; echo '<td><strong><a href="post.php?post=' . $product['id'] . '&action=edit">' . $product['name'] . '</a></strong>'; echo '<div class="row-actions">'; echo '<span><a href="edit.php?foxyshop_manage_google_feed=1&addid=' . $product['id'] . $debug_querystring . '&_wpnonce=' . wp_create_nonce("manage-the-google-feed-settings") . '" class="insert_google_product" rel="' . $google_product_id . '">' . __('Add To Google Products Feed', 'foxyshop') . '</a></span>'; echo '</div>'; echo '</td>' . "\n"; echo '<td>' . $product['code'] . '</td>' . "\n"; echo '<td><img src="' . foxyshop_get_main_image() . '" class="productfeedimage" /></td>' . "\n"; echo '<td>' . $pricewrite . '</td>' . "\n"; echo '<td>' . Date("Y-m-d", strtotime($single_product->post_date)) . '</td>' . "\n"; echo '</tr>' . "\n"; } if ($none_available) { echo '<tr><td colspan="7"><em>No ' . FOXYSHOP_PRODUCT_NAME_PLURAL . ' Available.</em></td></tr>' . "\n"; } ?> </tbody> </table> <input type="hidden" name="foxyshop_run_the_xml" value="1" /> <?php wp_nonce_field('manage-the-google-feed-settings'); ?> <?php if (isset($_GET['debug'])) { echo '<input type="hidden" name="debug" value="1" />'; } ?> <div style="padding-top: 10px;"> <button type="submit" class="button" name="add_checked_google_products" value="1" id="add_checked_google_products">Add Checked <?php echo FOXYSHOP_PRODUCT_NAME_PLURAL; ?> to Google</button> </div> </form> <?php } ?> <?php } ?> <br /><br /><br /><br /><br /><br /> <table class="widefat"> <thead> <tr> <th><img src="<?php echo $google_icon; ?> " alt="" /><?php _e("Create Manual Export File"); ?> </th> </tr> </thead> <tbody> <tr> <td> <p>If you would like to <a href="http://www.google.com/merchants" target="_blank">submit your products to Google</a>, you may do so by creating a product feed using this tool. Make sure that you check the option that <a href="http://www.google.com/support/merchants/bin/answer.py?answer=160037" target="_blank">enables double quotes.</a> You also need to make sure that the '_google_product_category' custom field is filled out for each product.</p> <form action="edit.php" method="get"> <input type="hidden" name="post_type" value="foxyshop_product"> <input type="hidden" name="create_google_product_feed" value="1"> <p> <a href="#" onclick="jQuery('#db_export_settings').show(); jQuery(this).hide(); return false;">Export just part of your product database</a> <div id="db_export_settings" style="display: none;"> <label for="records_per_page">How May Records Per Page?</label><input type="text" id="records_per_page" name="records_per_page" value="-1"> (-1 for all)<br> <label for="records_page">Which Page To Export?</label><input type="text" id="records_page" name="records_page" value="1"> </div> <button type="submit" name="submitnow" id="submitnow" value="1" class="button-primary">Create Google Product Feed</button> <button type="submit" name="amazon_version" id="amazon_version" value="1" class="button-primary">Create Amazon Product Ads Feed</button> </p> </form> </td> </tr> </tbody> </table> </div> <script type="text/javascript" src="<?php echo FOXYSHOP_DIR; ?> /js/jquery.tablesorter.js"></script> <script type="text/javascript"> jQuery(document).ready(function($){ $("#product_feed_view").tablesorter({ 'cssDesc': 'asc sorted', 'cssAsc': 'desc sorted', 'headers': { 0: { sorter: false} } }); }); </script> <?php }
function foxyshop_subscription_management() { global $foxyshop_settings, $wp_version, $product; //Setup Fields and Defaults $foxy_data_defaults = array("is_active_filter" => "", "frequency_filter" => "", "past_due_amount_filter" => "", "start_date_filter_begin" => date("Y-m-d", strtotime("-10 days")), "start_date_filter_end" => date("Y-m-d"), "next_transaction_date_filter_begin" => "", "next_transaction_date_filter_end" => "", "end_date_filter_begin" => "", "end_date_filter_end" => "", "third_party_id_filter" => "", "last_transaction_id_filter" => "", "customer_id_filter" => "", "customer_email_filter" => "", "customer_first_name_filter" => "", "customer_last_name_filter" => "", "product_code_filter" => "", "product_name_filter" => "", "product_option_name_filter" => "", "product_option_value_filter" => ""); if (version_compare($foxyshop_settings['version'], '0.7.2', ">=")) { $foxy_data_defaults["custom_field_name_filter"] = ""; $foxy_data_defaults["custom_field_value_filter"] = ""; } $foxy_data = wp_parse_args(array("api_action" => "subscription_list"), apply_filters('foxyshop_subscription_filter_defaults', $foxy_data_defaults)); $foxyshop_querystring = "?post_type=foxyshop_product&page=foxyshop_subscription_management&foxyshop_search=1"; $foxyshop_hidden_input = ""; if (isset($_GET['foxyshop_search']) || !defined('FOXYSHOP_AUTO_API_DISABLED')) { $fields = array("is_active_filter", "frequency_filter", "past_due_amount_filter", "start_date_filter_begin", "start_date_filter_end", "next_transaction_date_filter_begin", "next_transaction_date_filter_end", "end_date_filter_begin", "end_date_filter_end", "third_party_id_filter", "last_transaction_id_filter", "customer_id_filter", "customer_email_filter", "customer_first_name_filter", "customer_last_name_filter", "product_code_filter", "product_name_filter", "product_option_name_filter", "product_option_value_filter", "custom_field_name_filter", "custom_field_value_filter"); foreach ($fields as $field) { if (isset($_GET[$field])) { $foxy_data[$field] = $_GET[$field]; $foxyshop_querystring .= "&{$field}=" . urlencode($_GET[$field]); $foxyshop_hidden_input .= '<input type="hidden" name="' . $field . '" value="' . htmlspecialchars($_GET[$field]) . '" />' . "\n"; } } $foxy_data['pagination_start'] = isset($_GET['pagination_start']) ? $_GET['pagination_start'] : 0; $p = (int) (version_compare($foxyshop_settings['version'], '0.7.1', "<") ? 50 : FOXYSHOP_API_ENTRIES_PER_PAGE); if (version_compare($foxyshop_settings['version'], '0.7.0', ">")) { $foxy_data['entries_per_page'] = $p; } $start_offset = (int) (version_compare($foxyshop_settings['version'], '0.7.1', "<=") ? -1 : 0); if (isset($_GET['paged-top']) || isset($_GET['paged-bottom'])) { if ($_GET['paged-top'] != $_GET['paged-top-original']) { $foxy_data['pagination_start'] = $p * ((int) $_GET['paged-top'] - 1) + 1 + $start_offset; } if ($_GET['paged-bottom'] != $_GET['paged-bottom-original']) { $foxy_data['pagination_start'] = $p * ((int) $_GET['paged-bottom'] - 1) + 1 + $start_offset; } } } $subscription_products = get_posts(array('post_type' => 'foxyshop_product', "meta_key" => "_sub_frequency", "meta_value" => "", 'meta_compare' => '!=', "_sub_frequency", 'numberposts' => -1)); $subscription_product_array = array(); foreach ($subscription_products as $subscription_product) { $product = foxyshop_setup_product($subscription_product); $subscription_product_array[] = array("id" => $product['id'], "name" => $product['name'], "price" => $product['price']); } ?> <div class="wrap"> <div class="icon32 icon32-posts-page" id="icon-edit-pages"><br></div> <h2><?php _e('Manage Subscriptions', 'foxyshop'); ?> </h2> <form action="edit.php" method="get" id="foxyshop_searchform" name="foxyshop_searchform" style="display: block; margin: 14px 0 20px 0;"> <input type="hidden" name="foxyshop_search" value="1" /> <input type="hidden" name="post_type" value="foxyshop_product" /> <input type="hidden" name="page" value="foxyshop_subscription_management" /> <table class="widefat"> <thead><tr><th colspan="2"><img src="<?php echo FOXYSHOP_DIR; ?> /images/search-icon.png" alt="" /><?php _e('Search Options', 'foxyshop'); ?> </th></tr></thead> <tbody><tr><td> <div class="foxyshop_field_control"> <label for="is_active_filter"><?php _e('Subscription Type', 'foxyshop'); ?> </label> <select name="is_active_filter" id="is_active_filter"> <?php $selectArray = array("0" => __("Disabled", 'foxyshop'), "1" => __("Active", 'foxyshop'), "" => __("Both", 'foxyshop')); foreach ($selectArray as $selectKey => $selectOption) { echo '<option value="' . $selectKey . '"' . ($foxy_data['is_active_filter'] == $selectKey ? ' selected="selected"' : '') . '>' . $selectOption . '</option>' . "\n"; } ?> </select> </div> <div class="foxyshop_field_control"> <label for="past_due_amount_filter"><?php _e('Past Due Status', 'foxyshop'); ?> </label> <select name="past_due_amount_filter" id="past_due_amount_filter"> <?php $selectArray = array("" => __('Show All', 'foxyshop'), "1" => __('Show Past Due Only', 'foxyshop')); foreach ($selectArray as $selectKey => $selectOption) { echo '<option value="' . $selectKey . '"' . ($foxy_data['past_due_amount_filter'] == $selectKey ? ' selected="selected"' : '') . '>' . $selectOption . '</option>' . "\n"; } ?> </select> </div> <div class="foxyshop_field_control"> <label for="frequency_filter"><?php _e('Frequency', 'foxyshop'); ?> </label><input type="text" name="frequency_filter" id="frequency_filter" value="<?php echo $foxy_data['frequency_filter']; ?> " /> </div> <div class="foxyshop_field_control"> <label for="third_party_id_filter"><?php _e('Third Party ID', 'foxyshop'); ?> </label><input type="text" name="third_party_id_filter" id="third_party_id_filter" value="<?php echo $foxy_data['third_party_id_filter']; ?> " /> <span>PayPal</span> </div> <div class="foxyshop_field_control"> <label for="last_transaction_id_filter"><?php _e('Last Transaction ID', 'foxyshop'); ?> </label><input type="text" name="last_transaction_id_filter" id="last_transaction_id_filter" value="<?php echo $foxy_data['last_transaction_id_filter']; ?> " /> </div> <div class="foxyshop_field_control"> <label for="product_code_filter"><?php echo FOXYSHOP_PRODUCT_NAME_SINGULAR . ' ' . __('Code', 'foxyshop'); ?> </label><input type="text" name="product_code_filter" id="product_code_filter" value="<?php echo $foxy_data['product_code_filter']; ?> " /> </div> <div class="foxyshop_field_control"> <label for="product_name_filter"><?php echo FOXYSHOP_PRODUCT_NAME_SINGULAR . ' ' . __('Name', 'foxyshop'); ?> </label><input type="text" name="product_name_filter" id="product_name_filter" value="<?php echo $foxy_data['product_name_filter']; ?> " /> </div> <div class="foxyshop_field_control"> <label for="product_option_name_filter"><?php echo FOXYSHOP_PRODUCT_NAME_SINGULAR . ' ' . __('Option Name', 'foxyshop'); ?> </label><input type="text" name="product_option_name_filter" id="product_option_name_filter" value="<?php echo $foxy_data['product_option_name_filter']; ?> " /> <label for="product_option_value_filter" style="margin-left: 15px; margin-top: 4px; width: 38px;"><?php _e('Value', 'foxyshop'); ?> </label><input type="text" name="product_option_value_filter" id="product_option_value_filter" value="<?php echo $foxy_data['product_option_value_filter']; ?> " /> </div> <?php if (version_compare($foxyshop_settings['version'], '0.7.2', ">=")) { ?> <div class="foxyshop_field_control"> <label for="custom_field_name_filter"><?php _e('Custom Field Name', 'foxyshop'); ?> </label><input type="text" name="custom_field_name_filter" id="custom_field_name_filter" value="<?php echo $foxy_data['custom_field_name_filter']; ?> " /> <label for="custom_field_value_filter" style="margin-left: 15px; margin-top: 4px; width: 38px;"><?php _e('Value', 'foxyshop'); ?> </label><input type="text" name="custom_field_value_filter" id="custom_field_value_filter" value="<?php echo $foxy_data['custom_field_value_filter']; ?> " /> </div> <?php } ?> </td><td> <div class="foxyshop_field_control"> <label for="start_date_filter_begin"><?php _e('Start Date', 'foxyshop'); ?> </label> <input type="text" name="start_date_filter_begin" id="start_date_filter_begin" value="<?php echo $foxy_data['start_date_filter_begin']; ?> " class="foxyshop_date_field" /> <span><?php _e('to', 'foxyshop'); ?> </span> <input type="text" name="start_date_filter_end" id="start_date_filter_end" value="<?php echo $foxy_data['start_date_filter_end']; ?> " class="foxyshop_date_field" /> </div> <div class="foxyshop_field_control"> <label for="next_transaction_date_filter_begin"><?php _e('Next Transaction Date', 'foxyshop'); ?> </label> <input type="text" name="next_transaction_date_filter_begin" id="next_transaction_date_filter_begin" value="<?php echo $foxy_data['next_transaction_date_filter_begin']; ?> " class="foxyshop_date_field" /> <span><?php _e('to', 'foxyshop'); ?> </span> <input type="text" name="next_transaction_date_filter_end" id="next_transaction_date_filter_end" value="<?php echo $foxy_data['next_transaction_date_filter_end']; ?> " class="foxyshop_date_field" /> </div> <div class="foxyshop_field_control"> <label for="end_date_filter_begin"><?php _e('End Date', 'foxyshop'); ?> </label> <input type="text" name="end_date_filter_begin" id="end_date_filter_begin" value="<?php echo $foxy_data['end_date_filter_begin']; ?> " class="foxyshop_date_field" /> <span><?php _e('to', 'foxyshop'); ?> </span> <input type="text" name="end_date_filter_end" id="end_date_filter_end" value="<?php echo $foxy_data['end_date_filter_end']; ?> " class="foxyshop_date_field" /> </div> <div class="foxyshop_field_control"> <label for="customer_id_filter"><?php _e('Customer ID', 'foxyshop'); ?> </label><input type="text" name="customer_id_filter" id="customer_id_filter" value="<?php echo $foxy_data['customer_id_filter']; ?> " /> </div> <div class="foxyshop_field_control"> <label for="customer_email_filter"><?php _e('Customer Email', 'foxyshop'); ?> </label><input type="text" name="customer_email_filter" id="customer_email_filter" value="<?php echo $foxy_data['customer_email_filter']; ?> " /> </div> <div class="foxyshop_field_control"> <label for="customer_first_name_filter"><?php _e('Customer First Name', 'foxyshop'); ?> </label><input type="text" name="customer_first_name_filter" id="customer_first_name_filter" value="<?php echo $foxy_data['customer_first_name_filter']; ?> " /> </div> <div class="foxyshop_field_control"> <label for="customer_last_name_filter"><?php _e('Customer Last Name', 'foxyshop'); ?> </label><input type="text" name="customer_last_name_filter" id="customer_last_name_filter" value="<?php echo $foxy_data['customer_last_name_filter']; ?> " /> </div> <div style="clear: both;"></div> <button type="submit" id="foxyshop_search_submit" name="foxyshop_search_submit" class="button-primary" style="clear: both; margin-top: 10px;"><?php _e('Search Records Now', 'foxyshop'); ?> </button> <button type="button" class="button" style="margin-left: 15px; margin-top: 10px;" onclick="document.location.href = 'edit.php?post_type=foxyshop_product&page=foxyshop_subscription_management';"><?php _e('Reset Form', 'foxyshop'); ?> </button> </td></tr></tbody></table> </form> <script type="text/javascript" charset="utf-8"> jQuery(document).ready(function($) { $(".foxyshop_date_field").datepicker({ dateFormat: 'yy-mm-dd' }); }); </script> <?php if (!isset($_GET['foxyshop_search']) && defined('FOXYSHOP_AUTO_API_DISABLED')) { return; } $foxy_response = foxyshop_get_foxycart_data($foxy_data); $xml = simplexml_load_string($foxy_response, NULL, LIBXML_NOCDATA); if ((string) $xml->result == __('ERROR', 'foxyshop')) { echo '<h3>' . (string) $xml->messages->message . '</h3>'; return; } else { ?> <form action="edit.php" method="get"> <input type="hidden" name="foxyshop_search" value="1" /> <input type="hidden" name="post_type" value="foxyshop_product" /> <input type="hidden" name="page" value="foxyshop_subscription_management" /> <?php echo $foxyshop_hidden_input; foxyshop_api_paging_nav('subscriptions', 'top', $xml, $foxyshop_querystring); ?> <table cellpadding="0" cellspacing="0" border="0" class="wp-list-table widefat foxyshop-list-table" id="subscription_table"> <thead> <tr> <th><span><?php _e('Customer', 'foxyshop'); ?> </span><span class="sorting-indicator"></span></th> <th><span><?php _e('Start Date', 'foxyshop'); ?> </span><span class="sorting-indicator"></span></th> <th><span><?php _e('Next Date', 'foxyshop'); ?> </span><span class="sorting-indicator"></span></th> <th><span><?php _e('End Date', 'foxyshop'); ?> </span><span class="sorting-indicator"></span></th> <th><span><?php _e('Past Due', 'foxyshop'); ?> </span><span class="sorting-indicator"></span></th> <th><span><?php _e('Details', 'foxyshop'); ?> </span><span class="sorting-indicator"></span></th> <th><span><?php _e('Frequency', 'foxyshop'); ?> </span><span class="sorting-indicator"></span></th> </tr> </thead> <tfoot> <tr> <th><?php _e('Customer', 'foxyshop'); ?> </th> <th><?php _e('Start Date', 'foxyshop'); ?> </th> <th><?php _e('Next Date', 'foxyshop'); ?> </th> <th><?php _e('End Date', 'foxyshop'); ?> </th> <th><?php _e('Past Due', 'foxyshop'); ?> </th> <th><?php _e('Details', 'foxyshop'); ?> </th> <th><?php _e('Frequency', 'foxyshop'); ?> </th> </tr> </tfoot> <tbody id="the-list"> <?php $holder = ""; foreach ($xml->subscriptions->subscription as $subscription) { $sub_token = (string) $subscription->sub_token; $customer_id = (string) $subscription->customer_id; $customer_first_name = (string) $subscription->customer_first_name; $customer_last_name = (string) $subscription->customer_last_name; $start_date = (string) $subscription->start_date; $next_transaction_date = (string) $subscription->next_transaction_date; $end_date = (string) $subscription->end_date; $frequency = (string) $subscription->frequency; $past_due_amount = (string) $subscription->past_due_amount; $is_active = (string) $subscription->is_active; $product_name = ""; if (version_compare($foxyshop_settings['version'], '0.7.0', ">")) { foreach ($subscription->transaction_template->transaction_details->transaction_detail as $transaction_detail) { if ($product_name) { $product_name .= "<br />"; } $product_price = (double) $transaction_detail->product_price; foreach ($transaction_detail->transaction_detail_options->transaction_detail_option as $transaction_detail_option) { $product_price += (double) $transaction_detail_option->price_mod; } $product_name .= (string) $transaction_detail->product_name . ' ' . foxyshop_currency($product_price); } } else { // The 0.7.0 code had an extra transaction_template node which was removed in subsequent versions foreach ($subscription->transaction_template->transaction_template->transaction_details->transaction_detail as $transaction_detail) { if ($product_name) { $product_name .= "<br />"; } $product_price = (double) $transaction_detail->product_price; foreach ($transaction_detail->transaction_detail_options->transaction_detail_option as $transaction_detail_option) { $product_price += (double) $transaction_detail_option->price_mod; } $product_name .= (string) $transaction_detail->product_name . ' ' . foxyshop_currency($product_price); } } if ($customer_first_name != "") { $customer_name = $customer_last_name . ', ' . $customer_first_name; } else { $customer_name = $customer_id; } echo '<tr rel="' . $sub_token . '">'; echo '<td class="customer_name">'; echo '<strong' . ($is_active == "0" ? ' class="strikethrough"' : '') . '><a href="#" class="view_detail">' . $customer_name . '</a></strong>'; echo '<div class="row-actions">'; echo '<span class="edit"><a title="' . __('Edit') . '" href="#" class="view_detail">' . __('Edit') . '</a> | </span>'; echo '<span class="view_customer"><a href="edit.php?post_type=foxyshop_product&page=foxyshop_customer_management&customer_id_filter=' . $customer_id . '&foxyshop_search=1" title="' . __('Customer') . '">' . __('Customer') . '</a></span>'; do_action('foxyshop_subscription_action_line', $subscription); echo '</div>'; echo '</td>'; echo '<td class="start_date">' . $start_date . '</td>'; echo '<td class="next_transaction_date">' . $next_transaction_date . '</td>'; echo '<td class="end_date">' . $end_date . '</td>'; echo '<td class="past_due_amount">' . $past_due_amount . '</td>'; echo '<td class="product_description">' . $product_name . '</td>'; echo '<td class="frequency">' . $frequency . '</td>'; echo "</tr>\n"; $holder .= '<div class="detail_holder" id="holder_' . $sub_token . '">' . "\n"; $holder .= '<form class="subscription_update_form" name="subscription_update_form_' . $sub_token . '" id="subscription_update_form_' . $sub_token . '" onsubmit="return false;">' . "\n"; $holder .= '<div class="foxyshop_field_control">' . "\n"; $holder .= '<label>' . __('Subscription Status', 'foxyshop') . '</label>' . "\n"; $holder .= '<input type="radio" name="is_active" id="is_active_1_' . $sub_token . '" value="1"' . ($is_active == "1" ? ' checked="checked"' : '') . ' style="float: left; margin-top: 7px;" />' . "\n"; $holder .= '<label for="is_active_1_' . $sub_token . '" style="width: 55px;">' . __('Active', 'foxyshop') . '</label>' . "\n"; $holder .= '<input type="radio" name="is_active" id="is_active_0_' . $sub_token . '" value="0"' . ($is_active == "0" ? ' checked="checked"' : '') . ' style="float: left; margin-top: 7px;" />' . "\n"; $holder .= '<label for="is_active_0_' . $sub_token . '">' . __('In-active', 'foxyshop') . '</label>' . "\n"; $holder .= '</div>' . "\n"; $holder .= '<div class="foxyshop_field_control">' . "\n"; $holder .= '<label for="start_date_' . $sub_token . '">' . __('Start Date', 'foxyshop') . '</label>' . "\n"; $holder .= '<input type="text" name="start_date" id="start_date_' . $sub_token . '" class="foxyshop_date_field" value="' . (string) $subscription->start_date . '" /><span>(YYYY-MM-DD)</span>' . "\n"; $holder .= '</div>' . "\n"; $holder .= '<div class="foxyshop_field_control">' . "\n"; $holder .= '<label for="next_transaction_date_' . $sub_token . '">' . __('Next Transaction Date', 'foxyshop') . '</label>' . "\n"; $holder .= '<input type="text" name="next_transaction_date" id="next_transaction_date_' . $sub_token . '" value="' . (string) $subscription->next_transaction_date . '" class="foxyshop_date_field" /><span>(YYYY-MM-DD)</span>' . "\n"; $holder .= '</div>' . "\n"; $holder .= '<div class="foxyshop_field_control">' . "\n"; $holder .= '<label for="end_date_' . $sub_token . '">' . __('End Date', 'foxyshop') . '</label>' . "\n"; $holder .= '<input type="text" name="end_date" id="end_date_' . $sub_token . '" value="' . $end_date . '" class="foxyshop_date_field" /><span>(YYYY-MM-DD)</span> <a href="#" onclick="jQuery(\'#end_date_' . $sub_token . '\').val(\'0000-00-00\'); this.blur(); return false;" class="button" style="margin: 5px 0 0 5px; float: left;">Never</a> <a href="#" onclick="jQuery(\'#end_date_' . $sub_token . '\').val(\'' . date("Y-m-d", strtotime("+1 day")) . '\'); this.blur(); return false;" class="button" style="margin: 5px 0 0 5px; float: left;">Tomorrow</a>' . "\n"; $holder .= '</div>' . "\n"; $holder .= '<div class="foxyshop_field_control">' . "\n"; $holder .= '<label for="frequency_' . $sub_token . '">' . __('Frequency', 'foxyshop') . '</label>' . "\n"; $holder .= '<input type="text" name="frequency" id="frequency_' . $sub_token . '" value="' . $frequency . '" /><span>(60d, 2w, 1m, 1y, .5m)</span>' . "\n"; $holder .= '</div>' . "\n"; $holder .= '<div class="foxyshop_field_control">' . "\n"; $holder .= '<label for="past_due_amount_' . $sub_token . '">' . __('Past Due Amount', 'foxyshop') . '</label>' . "\n"; $holder .= '<input type="text" name="past_due_amount" id="past_due_amount_' . $sub_token . '" value="' . $past_due_amount . '" onblur="foxyshop_check_number(this);" /><span>(0.00)</span>' . "\n"; $holder .= '</div>' . "\n"; $holder .= '<div class="foxyshop_field_control">' . "\n"; $holder .= '<label for="update_url_' . $sub_token . '">' . __('Update URL', 'foxyshop') . '</label>' . "\n"; $holder .= '<input type="text" name="update_url" id="update_url_' . $sub_token . '" value="https://' . $foxyshop_settings['domain'] . '/cart?sub_token=' . $sub_token . '&empty=true&cart=checkout" style="width: 390px;" onclick="this.select();" />' . "\n"; $holder .= '</div>' . "\n"; $holder .= '<div class="foxyshop_field_control">' . "\n"; $holder .= '<label for="cancel_url_' . $sub_token . '">' . __('Cancellation URL', 'foxyshop') . '</label>' . "\n"; $holder .= '<input type="text" name="cancel_url" id="cancel_url_' . $sub_token . '" value="https://' . $foxyshop_settings['domain'] . '/cart?sub_token=' . $sub_token . '&empty=true&cart=checkout&sub_cancel=true" style="width: 390px;" onclick="this.select();" />' . "\n"; $holder .= '</div>' . "\n"; $holder .= '<div class="foxyshop_field_control">' . "\n"; $holder .= '<label for="transaction_template_id_' . $sub_token . '">' . __('Transaction Template') . '</label>' . "\n"; $holder .= '<select name="transaction_template_id" id="transaction_template_id_' . $sub_token . '">' . "\n"; $holder .= '<option value="0">- - ' . __('Select Option Below', 'foxyshop') . ' - -</option>' . "\n"; foreach ($subscription_product_array as $key => $val) { $holder .= '<option value="' . $val['id'] . '">' . $val['name'] . ' ' . foxyshop_currency($val['price']) . '</option>' . "\n"; } $holder .= '</select>' . "\n"; $holder .= '</div>' . "\n"; $holder .= '<p style="padding-top: 5px; clear: both"><a href="#" class="subscription_save button-primary">' . __('Save Changes', 'foxyshop') . '</a> <a href="#" class="detail_close button">' . __('Cancel', 'foxyshop') . '</a></p>' . "\n"; $holder .= '<input type="hidden" name="sub_token" value="' . $sub_token . '" />' . "\n"; $holder .= '<input type="hidden" name="action" value="foxyshop_display_list_ajax_action" />' . "\n"; $holder .= '<input type="hidden" name="foxyshop_action" value="subscription_modify" />' . "\n"; $holder .= '<input type="hidden" name="security" value="' . wp_create_nonce("foxyshop-display-list-function") . '" />' . "\n"; //Custom Attributes $holder .= foxyshop_manage_attributes($subscription->attributes, $sub_token, "subscription"); $holder .= '</form>' . "\n"; $holder .= '</div>' . "\n"; } ?> </tbody> </table> <?php foxyshop_api_paging_nav('subscriptions', 'bottom', $xml, $foxyshop_querystring); ?> </form> <?php } ?> <div id="details_holder"><?php echo $holder; ?> </div> <script type="text/javascript" src="<?php echo FOXYSHOP_DIR; ?> /js/jquery.tablesorter.js"></script> <script type="text/javascript"> jQuery(document).ready(function($){ $(".foxyshop-list-table thead th").click(function() { $("#foxyshop-list-inline .detail_holder").appendTo("#details_holder"); $("#foxyshop-list-inline").remove(); }); $(".foxyshop-list-table").tablesorter({ 'cssDesc': 'asc sorted', 'cssAsc': 'desc sorted' }); $(".view_detail").click(function() { var id = $(this).parents("tr").attr("rel"); if ($("#foxyshop-list-inline #holder_" + id).length > 0) { $("#foxyshop-list-inline .detail_holder").appendTo("#details_holder"); $("#foxyshop-list-inline").remove(); } else { $("#details_holder select").prop('selectedIndex', 0); $("#foxyshop-list-inline .detail_holder").appendTo("#details_holder"); $("#foxyshop-list-inline").remove(); $(this).parents("tr").after('<tr id="foxyshop-list-inline"><td colspan="7"></td></tr>'); $("#holder_"+id).appendTo("#foxyshop-list-inline td"); } return false; }); $(".detail_close").click(function() { $("#foxyshop-list-inline .detail_holder").appendTo("#details_holder"); $("#foxyshop-list-inline").remove(); return false; }); $(".subscription_save").click(function() { var id = $(this).parents("form").children("input[name='sub_token']").val(); $.post(ajaxurl, $(this).parents("form").serialize(), function(response) { $("#foxyshop-list-inline .detail_holder").appendTo("#details_holder"); $("#foxyshop-list-inline").remove(); if (response.indexOf("ERROR") < 0) { $("tr[rel='" + id + "']").css("background-color", "#FFFFE0").delay(500).animate({ backgroundColor: 'transparent' }, 500); if ($("#is_active_0_" + id).is(":checked")) { $("tr[rel='" + id + "'] td.customer_name strong").addClass("strikethrough"); } else { $("tr[rel='" + id + "'] td.customer_name strong").removeClass("strikethrough"); } $("tr[rel='" + id + "'] td.start_date").text($("#start_date" + id).val()); $("tr[rel='" + id + "'] td.next_transaction_date").text($("#next_transaction_date_" + id).val()); $("tr[rel='" + id + "'] td.end_date").text($("#end_date_" + id).val()); $("tr[rel='" + id + "'] td.past_due_amount").text($("#past_due_amount_" + id).val()); $("tr[rel='" + id + "'] td.frequency").text($("#frequency_" + id).val()); if ($("#transaction_template_id_" + id).prop("selectedIndex") > 0) { $("tr[rel='" + id + "'] td.product_description").text($("#transaction_template_id_" + id + " option:selected").text()); } } else { alert(response); } }); return false; }); <?php foxyshop_manage_attributes_jquery('subscription'); ?> }); function foxyshop_format_number(num) { num = num.toString().replace(/\$|\,/g,''); if(isNaN(num)) num = "0"; sign = (num == (num = Math.abs(num))); num = Math.floor(num*100+0.50000000001); cents = num%100; num = Math.floor(num/100).toString(); if(cents<10) cents = "0" + cents; for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) num = num.substring(0,num.length-(4*i+3))+','+ num.substring(num.length-(4*i+3)); return (((sign)?'':'-') + num + '.' + cents); } function foxyshop_check_number(el) { el.value = foxyshop_format_number(el.value); } </script> <?php echo '</div>'; }
function foxyshop_customer_order_history($customer_id = 0, $date_filter = 'n/j/Y', $no_results_message = "No Records Found.") { global $foxyshop_settings; //Setup Fields and Defaults $foxy_data_defaults = array("customer_id_filter" => $customer_id); $foxy_data = wp_parse_args(array("api_action" => "transaction_list"), $foxy_data_defaults); $foxy_data['pagination_start'] = isset($_GET['pagination_start']) ? $_GET['pagination_start'] : 0; if (version_compare($foxyshop_settings['version'], '0.7.0', ">")) { $foxy_data['entries_per_page'] = 50; } $foxy_response = foxyshop_get_foxycart_data($foxy_data); $xml = simplexml_load_string($foxy_response, NULL, LIBXML_NOCDATA); //No Results if ($xml->result == "ERROR") { $msg = $xml->messages->message; if ($msg == "No transactions found. Please double check your filter fields.") { $msg = $no_results_message; } echo '<div class="foxyshop_customer_order_history_no_results">' . $msg . '</div>'; return; } //Table Header echo '<table cellpadding="0" cellspacing="0" border="0" class="foxyshop_table_list" id="foxyshop_customer_order_history">' . "\n"; echo '<thead>' . "\n"; echo '<tr>' . "\n"; echo '<th>Order ID</th>' . "\n"; echo '<th>Date</th>' . "\n"; echo '<th>Total</th>' . "\n"; echo '<th> </th>' . "\n"; echo '</tr>' . "\n"; echo '</thead>' . "\n"; echo '<tbody>' . "\n"; foreach ($xml->transactions->transaction as $transaction) { $transaction_id = $transaction->id; echo '<tr rel="' . $transaction_id . '">'; echo '<td class="order_id">' . $transaction_id . '</td>'; echo '<td class="order_date">' . date($date_filter, strtotime($transaction->transaction_date)) . '</td>'; echo '<td class="order_total">' . foxyshop_currency((double) $transaction->order_total) . '</td>'; echo '<td class="order_receipt"><a href="' . $transaction->receipt_url . '" target="_blank">Show Receipt</a></td>'; echo '</tr>' . "\n"; } echo '</tbody></table>'; //Pagination $p = (int) (version_compare($foxyshop_settings['version'], '0.7.0', "==") ? 50 : 50); $total_records = (int) $xml->statistics->total_orders; $filtered_total = (int) $xml->statistics->filtered_total; $pagination_start = (int) $xml->statistics->pagination_start; $pagination_end = (int) $xml->statistics->pagination_end; if ($pagination_start > 1 || $filtered_total > $pagination_end) { echo '<div id="foxyshop_list_pagination">'; echo $xml->messages->message[1] . '<br />'; if ($pagination_start > 1) { echo '<a href="edit.php' . $querystring . '&pagination_start=' . ($pagination_start - $p - 1) . '">« Previous</a>'; } if ($pagination_end < $filtered_total) { if ($pagination_start > 1) { echo ' | '; } echo '<a href="edit.php' . $querystring . '&pagination_start=' . $pagination_end . '">Next »</a>'; } echo '</div>'; } }
function foxyshop_manage_custom_columns($column_name, $id) { global $wpdb, $foxyshop_settings; switch ($column_name) { case 'id': echo $id; break; case 'productcategory': $_taxonomy = 'foxyshop_categories'; $terms = get_the_terms($id, $_taxonomy); if (!empty($terms)) { $out = array(); foreach ($terms as $c) { $out[] = "<a href='edit-tags.php?action=edit&taxonomy={$_taxonomy}&post_type=book&tag_ID={$c->term_id}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>"; } echo join(', ', $out); } else { _e('Uncategorized', 'foxyshop'); } break; case 'productimage': $featuredImageID = has_post_thumbnail($id) ? get_post_thumbnail_id($id) : 0; $imageNumber = 0; $src = ""; $attachments = get_posts(array('numberposts' => -1, 'post_type' => 'attachment', 'post_status' => null, 'post_parent' => $id, 'order' => 'ASC', 'orderby' => 'menu_order')); if (!$attachments && $featuredImageID) { $attachments = get_posts(array("p" => $featuredImageID, 'post_type' => 'attachment', "post_mime_type" => "image")); } foreach ($attachments as $attachment) { $thumbnailSRC = wp_get_attachment_image_src($attachment->ID, "thumbnail"); if ($featuredImageID == $attachment->ID || $featuredImageID == 0 && $imageNumber == 0) { $src = $thumbnailSRC[0]; } $imageNumber++; } if (!$src && $featuredImageID) { $arr = wp_get_attachment_image_src($featuredImageID, "thumbnail"); $src = $arr[0]; } if (!$src) { $src = $foxyshop_settings['default_image']; } if (!$src) { $src = WP_PLUGIN_URL . "/foxyshop/images/no-photo.png"; } echo $src != 'none' ? '<a href="post.php?post=' . $id . '&action=edit"><img src="' . $src . '" alt="" /></a>' : ' '; break; case 'productcode': $productcode = get_post_meta($id, "_code", true); echo $productcode ? $productcode : '(' . $id . ')'; break; case 'price': $salestartdate = get_post_meta($id, '_salestartdate', TRUE); $saleenddate = get_post_meta($id, '_saleenddate', TRUE); if ($salestartdate == '999999999999999999') { $salestartdate = 0; } if ($saleenddate == '999999999999999999') { $saleenddate = 0; } $originalprice = get_post_meta($id, '_price', true); $saleprice = get_post_meta($id, '_saleprice', true); if ($saleprice > 0) { $beginningOK = strtotime("now") > $salestartdate; $endingOK = strtotime("now") < $saleenddate + 86400 || $saleenddate == 0; if ($beginningOK && $endingOK || $salestartdate == 0 && $saleenddate == 0) { echo '<span style="text-decoration: line-through; margin-right: 10px;">' . foxyshop_currency($originalprice) . '</span><span style="color: red;">' . foxyshop_currency($saleprice) . '</span>'; } else { echo foxyshop_currency($originalprice); } } else { echo foxyshop_currency($originalprice); } break; default: } }
function foxyshop_order_history_dashboard_ajax() { global $foxyshop_settings; check_ajax_referer('foxyshop-order-info-dashboard', 'security'); $pagination_start = 1; $filtered_total = 2; $orderstats = array(1 => array(0, 0), 7 => array(0, 0), 30 => array(0, 0)); while ($pagination_start < $filtered_total) { //Get Order Info $foxy_data = array("api_action" => "transaction_list", "entries_per_page" => 50, "pagination_start" => $pagination_start, "transaction_date_filter_begin" => date("Y-m-d", strtotime("-30 days")), "transaction_date_filter_end" => date("Y-m-d"), "is_test_filter" => 0, "hide_transaction_filter" => ""); $foxy_response = foxyshop_get_foxycart_data($foxy_data); $xml = simplexml_load_string($foxy_response, NULL, LIBXML_NOCDATA); if ($xml->result != "ERROR") { $filtered_total = (int) $xml->statistics->filtered_total; $pagination_start = (int) $xml->statistics->pagination_end + 1; foreach ($xml->transactions->transaction as $transaction) { $transaction_date = (string) $transaction->transaction_date; $transaction_total = (double) $transaction->order_total; if (strtotime($transaction_date) >= strtotime("-24 hours")) { $orderstats[1][0]++; $orderstats[1][1] += $transaction_total; } if (strtotime($transaction_date) >= strtotime("-7 days")) { $orderstats[7][0]++; $orderstats[7][1] += $transaction_total; } $orderstats[30][0]++; $orderstats[30][1] += $transaction_total; } } else { $filtered_total = 0; } } echo '<li>' . __('One Day', 'foxyshop') . ': <a href="edit.php?foxyshop_search=1&is_test_filter=&post_type=foxyshop_product&page=foxyshop_order_management&transaction_date_filter_begin=' . date("Y-m-d", strtotime("-1 day")) . '&transaction_date_filter_end=' . date("Y-m-d") . '">' . $orderstats[1][0] . ' ' . _n('order', 'orders', $orderstats[1][0], 'foxyshop') . ', ' . foxyshop_currency($orderstats[1][1]) . '</a></li>' . "\n"; echo '<li>' . __('Seven Days', 'foxyshop') . ': <a href="edit.php?foxyshop_search=1&is_test_filter=&post_type=foxyshop_product&page=foxyshop_order_management&transaction_date_filter_begin=' . date("Y-m-d", strtotime("-7 days")) . '&transaction_date_filter_end=' . date("Y-m-d") . '">' . $orderstats[7][0] . ' ' . _n('order', 'orders', $orderstats[7][0], 'foxyshop') . ', ' . foxyshop_currency($orderstats[7][1]) . '</a></li>' . "\n"; echo '<li>' . __('30 Days', 'foxyshop') . ': <a href="edit.php?foxyshop_search=1&is_test_filter=&post_type=foxyshop_product&page=foxyshop_order_management&transaction_date_filter_begin=' . date("Y-m-d", strtotime("-30 days")) . '&transaction_date_filter_end=' . date("Y-m-d") . '">' . $orderstats[30][0] . ' ' . _n('order', 'orders', $orderstats[30][0], 'foxyshop') . ', ' . foxyshop_currency($orderstats[30][1]) . '</a></li>' . "\n"; die; }
echo (string) $discount->name; ?> :</td> <td class="short_cell bold"><?php echo foxyshop_currency((double) $discount->amount); ?> </td> </tr> <?php } ?> <tr> <td> </td> <td colspan="2" align="right">Total:</td> <td class="short_cell bold"><?php echo foxyshop_currency((double) $transaction->order_total); ?> </td> </tr> </table> </div> </div> <?php //Show a Nice Shadow Image at the Bottom of The Table ?> <div style="text-align:center;"><img src="<?php echo FOXYSHOP_DIR; ?> /images/paper-shadow.png" width="505" height="8" alt="shadow" /></div>
function foxyshop_order_management() { global $foxyshop_settings, $wp_version; //Setup Fields and Defaults $foxy_data_defaults = array("is_test_filter" => "0", "hide_transaction_filter" => "0", "data_is_fed_filter" => "", "id_filter" => "", "order_total_filter" => "", "coupon_code_filter" => "", "transaction_date_filter_begin" => date("Y-m-d", strtotime("-10 days")), "transaction_date_filter_end" => date("Y-m-d"), "customer_id_filter" => "", "customer_email_filter" => "", "customer_first_name_filter" => "", "customer_last_name_filter" => "", "customer_state_filter" => "", "shipping_state_filter" => "", "customer_ip_filter" => "", "product_code_filter" => "", "product_name_filter" => "", "product_option_name_filter" => "", "product_option_value_filter" => ""); if (version_compare($foxyshop_settings['version'], '0.7.2', ">=")) { $foxy_data_defaults["custom_field_name_filter"] = ""; $foxy_data_defaults["custom_field_value_filter"] = ""; } $foxy_data = wp_parse_args(array("api_action" => "transaction_list"), apply_filters('foxyshop_transaction_filter_defaults', $foxy_data_defaults)); $foxyshop_querystring = "?post_type=foxyshop_product&page=foxyshop_order_management&foxyshop_search=1"; $foxyshop_hidden_input = ""; if (isset($_GET['foxyshop_search']) || !defined('FOXYSHOP_AUTO_API_DISABLED')) { $fields = array("is_test_filter", "hide_transaction_filter", "data_is_fed_filter", "id_filter", "order_total_filter", "coupon_code_filter", "transaction_date_filter_begin", "transaction_date_filter_end", "customer_id_filter", "customer_email_filter", "customer_first_name_filter", "customer_last_name_filter", "customer_state_filter", "shipping_state_filter", "customer_ip_filter", "product_code_filter", "product_name_filter", "product_option_name_filter", "product_option_value_filter", "custom_field_name_filter", "custom_field_value_filter"); foreach ($fields as $field) { if (isset($_GET[$field])) { $foxy_data[$field] = $_GET[$field]; $foxyshop_querystring .= "&{$field}=" . urlencode($_GET[$field]); $foxyshop_hidden_input .= '<input type="hidden" name="' . $field . '" value="' . htmlspecialchars($_GET[$field]) . '" />' . "\n"; } } $foxy_data['pagination_start'] = isset($_GET['pagination_start']) ? $_GET['pagination_start'] : 0; $p = (int) (version_compare($foxyshop_settings['version'], '0.7.1', "<") ? 50 : FOXYSHOP_API_ENTRIES_PER_PAGE); if (version_compare($foxyshop_settings['version'], '0.7.0', ">")) { $foxy_data['entries_per_page'] = $p; } $start_offset = (int) (version_compare($foxyshop_settings['version'], '0.7.1', "<=") ? -1 : 0); if (isset($_GET['paged-top']) || isset($_GET['paged-bottom'])) { if ($_GET['paged-top'] != $_GET['paged-top-original']) { $foxy_data['pagination_start'] = $p * ((int) $_GET['paged-top'] - 1) + 1 + $start_offset; } if ($_GET['paged-bottom'] != $_GET['paged-bottom-original']) { $foxy_data['pagination_start'] = $p * ((int) $_GET['paged-bottom'] - 1) + 1 + $start_offset; } } } $transaction_search_type = isset($_GET['transaction_search_type']) ? $_GET['transaction_search_type'] : ''; if ($foxyshop_settings["orderdesk_url"]) { $orderdesk_link = ' <a class="' . (version_compare(get_bloginfo('version'), '3.2', "<") ? "button " : '') . 'add-new-h2" href="https://app.orderdesk.me/" target="_blank">' . __('Launch Order Desk', 'foxyshop') . '</a>'; } else { $orderdesk_link = ""; } ?> <div class="wrap"> <div class="icon32 icon32-posts-page" id="icon-edit-pages"><br></div> <h2><?php _e('Manage Orders', 'foxyshop'); echo $orderdesk_link; ?> </h2> <form action="edit.php" method="get" id="foxyshop_searchform" name="foxyshop_searchform" style="display: block; margin: 14px 0 20px 0;"> <input type="hidden" name="foxyshop_search" value="1" /> <input type="hidden" name="post_type" value="foxyshop_product" /> <input type="hidden" name="page" value="foxyshop_order_management" /> <table class="widefat"> <thead><tr><th colspan="2"><img src="<?php echo FOXYSHOP_DIR; ?> /images/search-icon.png" alt="" /><?php _e('Search Options', 'foxyshop'); ?> </th></tr></thead> <tbody><tr><td> <div class="foxyshop_field_control foxyshop_radio_label_container"> <label><?php _e('Transaction Status', 'foxyshop'); ?> </label> <input type="radio" id="hide_transaction_filter0" name="hide_transaction_filter" value="0"<?php echo $foxy_data['hide_transaction_filter'] == 0 ? ' checked="checked"' : ''; ?> /> <label for="hide_transaction_filter0"><?php _e('Unfilled', 'foxyshop'); ?> </label> <input type="radio" id="hide_transaction_filter1" name="hide_transaction_filter" value="1"<?php echo $foxy_data['hide_transaction_filter'] == 1 ? ' checked="checked"' : ''; ?> /> <label for="hide_transaction_filter1"><?php _e('Filled', 'foxyshop'); ?> </label> <input type="radio" id="hide_transaction_filter" name="hide_transaction_filter" value=""<?php echo $foxy_data['hide_transaction_filter'] == '' ? ' checked="checked"' : ''; ?> /> <label for="hide_transaction_filter"><?php _e('Both', 'foxyshop'); ?> </label> </div> <div class="foxyshop_field_control foxyshop_radio_label_container"> <label><?php _e('Datafeed Status', 'foxyshop'); ?> </label> <input type="radio" id="data_is_fed_filter0" name="data_is_fed_filter" value="0"<?php echo $foxy_data['data_is_fed_filter'] == 0 ? ' checked="checked"' : ''; ?> /> <label for="data_is_fed_filter0"><?php _e('Fed', 'foxyshop'); ?> </label> <input type="radio" id="data_is_fed_filter1" name="data_is_fed_filter" value="1"<?php echo $foxy_data['data_is_fed_filter'] == 1 ? ' checked="checked"' : ''; ?> /> <label for="data_is_fed_filter1"><?php _e('Unfed', 'foxyshop'); ?> </label> <input type="radio" id="data_is_fed_filter" name="data_is_fed_filter" value=""<?php echo $foxy_data['data_is_fed_filter'] == '' ? ' checked="checked"' : ''; ?> /> <label for="data_is_fed_filter"><?php _e('Both', 'foxyshop'); ?> </label> </div> <div class="foxyshop_field_control foxyshop_radio_label_container"> <label><?php _e('Test Transactions', 'foxyshop'); ?> </label> <input type="radio" id="is_test_filter0" name="is_test_filter" value="0"<?php echo $foxy_data['is_test_filter'] == 0 ? ' checked="checked"' : ''; ?> /> <label for="is_test_filter0"><?php _e('Live', 'foxyshop'); ?> </label> <input type="radio" id="is_test_filter1" name="is_test_filter" value="1"<?php echo $foxy_data['is_test_filter'] == 1 ? ' checked="checked"' : ''; ?> /> <label for="is_test_filter1"><?php _e('Test', 'foxyshop'); ?> </label> <input type="radio" id="is_test_filter" name="is_test_filter" value=""<?php echo $foxy_data['is_test_filter'] == '' ? ' checked="checked"' : ''; ?> /> <label for="is_test_filter"><?php _e('Both', 'foxyshop'); ?> </label> </div> <div class="foxyshop_field_control"> <label for="order_id_filter"><?php _e('Order ID', 'foxyshop'); ?> </label><input type="text" name="id_filter" id="id_filter" value="<?php echo $foxy_data['id_filter']; ?> " /> </div> <div class="foxyshop_field_control"> <label for="order_total_filter"><?php _e('Order Total', 'foxyshop'); ?> </label><input type="text" name="order_total_filter" id="order_total_filter" value="<?php echo $foxy_data['order_total_filter']; ?> " /> </div> <div class="foxyshop_field_control"> <label for="coupon_code_filter"><?php _e('Coupon Code', 'foxyshop'); ?> </label><input type="text" name="coupon_code_filter" id="coupon_code_filter" value="<?php echo $foxy_data['coupon_code_filter']; ?> " /> </div> <div class="foxyshop_field_control"> <label for="product_code_filter"><?php echo FOXYSHOP_PRODUCT_NAME_SINGULAR . ' ' . __('Code', 'foxyshop'); ?> </label><input type="text" name="product_code_filter" id="product_code_filter" value="<?php echo $foxy_data['product_code_filter']; ?> " /> </div> <div class="foxyshop_field_control"> <label for="product_name_filter"><?php echo FOXYSHOP_PRODUCT_NAME_SINGULAR . ' ' . __('Name', 'foxyshop'); ?> </label><input type="text" name="product_name_filter" id="product_name_filter" value="<?php echo $foxy_data['product_name_filter']; ?> " /> </div> <div class="foxyshop_field_control"> <label for="product_option_name_filter"><?php echo FOXYSHOP_PRODUCT_NAME_SINGULAR . ' ' . __('Option Name', 'foxyshop'); ?> </label><input type="text" name="product_option_name_filter" id="product_option_name_filter" value="<?php echo $foxy_data['product_option_name_filter']; ?> " /> <label for="product_option_value_filter" style="margin-left: 15px; margin-top: 4px; width: 34px;"><?php _e('Value', 'foxyshop'); ?> </label><input type="text" name="product_option_value_filter" id="product_option_value_filter" value="<?php echo $foxy_data['product_option_value_filter']; ?> " /> </div> <?php if (version_compare($foxyshop_settings['version'], '0.7.2', ">=")) { ?> <div class="foxyshop_field_control"> <label for="custom_field_name_filter"><?php _e('Custom Field Name', 'foxyshop'); ?> </label><input type="text" name="custom_field_name_filter" id="custom_field_name_filter" value="<?php echo $foxy_data['custom_field_name_filter']; ?> " /> <label for="custom_field_value_filter" style="margin-left: 15px; margin-top: 4px; width: 34px;"><?php _e('Value', 'foxyshop'); ?> </label><input type="text" name="custom_field_value_filter" id="custom_field_value_filter" value="<?php echo $foxy_data['custom_field_value_filter']; ?> " /> </div> <?php } ?> </td><td> <div class="foxyshop_field_control"> <label for="transaction_date_filter_begin"><?php _e('Date Range', 'foxyshop'); ?> </label><input type="text" name="transaction_date_filter_begin" id="transaction_date_filter_begin" value="<?php echo $foxy_data['transaction_date_filter_begin']; ?> " class="foxyshop_date_field" /> <span><?php _e('to', 'foxyshop'); ?> </span><input type="text" name="transaction_date_filter_end" id="transaction_date_filter_end" value="<?php echo $foxy_data['transaction_date_filter_end']; ?> " class="foxyshop_date_field" /> </div> <div class="foxyshop_field_control"> <label for="customer_id_filter"><?php _e('Customer ID', 'foxyshop'); ?> </label><input type="text" name="customer_id_filter" id="customer_id_filter" value="<?php echo $foxy_data['customer_id_filter']; ?> " /> </div> <div class="foxyshop_field_control"> <label for="customer_email_filter"><?php _e('Customer Email', 'foxyshop'); ?> </label><input type="text" name="customer_email_filter" id="customer_email_filter" value="<?php echo $foxy_data['customer_email_filter']; ?> " /> </div> <div class="foxyshop_field_control"> <label for="customer_first_name_filter"><?php _e('Customer First Name', 'foxyshop'); ?> </label><input type="text" name="customer_first_name_filter" id="customer_first_name_filter" value="<?php echo $foxy_data['customer_first_name_filter']; ?> " /> </div> <div class="foxyshop_field_control"> <label for="customer_last_name_filter"><?php _e('Customer Last Name', 'foxyshop'); ?> </label><input type="text" name="customer_last_name_filter" id="customer_last_name_filter" value="<?php echo $foxy_data['customer_last_name_filter']; ?> " /> </div> <div class="foxyshop_field_control"> <label for="customer_state_filter"><?php _e('Customer State', 'foxyshop'); ?> </label><input type="text" name="customer_state_filter" id="customer_state_filter" value="<?php echo $foxy_data['customer_state_filter']; ?> " /> </div> <div class="foxyshop_field_control"> <label for="shipping_state_filter"><?php _e('Shipping State', 'foxyshop'); ?> </label><input type="text" name="shipping_state_filter" id="shipping_state_filter" value="<?php echo $foxy_data['shipping_state_filter']; ?> " /> </div> <div class="foxyshop_field_control"> <label for="customer_ip_filter"><?php _e('Customer IP', 'foxyshop'); ?> </label><input type="text" name="customer_ip_filter" id="customer_ip_filter" value="<?php echo $foxy_data['customer_ip_filter']; ?> " /> </div> <div style="clear: both;"></div> <select name="transaction_search_type" id="transaction_search_type"> <option value="show_orders"<?php echo $transaction_search_type == "show_orders" ? ' selected="selected"' : ''; ?> ><?php _e('Show Orders', 'foxyshop'); ?> </option> <option value="print_recipts" target="_blank"><?php _e('Print Receipts', 'foxyshop'); ?> </option> <?php if (!$foxyshop_settings['enable_ship_to']) { ?> <option value="export_csv"><?php _e('Export CSV', 'foxyshop'); ?> </option> <option value="export_tab"><?php _e('Export Tab Delimeted', 'foxyshop'); ?> </option> <option value="export_ups"><?php _e('Export to UPS', 'foxyshop'); ?> </option> <?php } ?> <?php do_action("foxyshop_order_search_list"); ?> </select> <button type="submit" id="foxyshop_search_submit" name="foxyshop_search_submit" class="button-primary" style="clear: left; margin-top: 10px;"><?php _e('Submit', 'foxyshop'); ?> </button> <button type="button" class="button submitcancel" style="margin-top: 10px;" onclick="document.location.href = 'edit.php?post_type=foxyshop_product&page=foxyshop_order_management';"><?php _e('Reset', 'foxyshop'); ?> </button> <div style="clear: both;"></div> <?php if (has_action('foxyshop_order_search_buttons')) { echo '<div id="foxyshop_order_search_buttons">'; do_action("foxyshop_order_search_buttons", $foxy_data); echo '</div>'; } ?> </td></tr></tbody></table> </form> <script type="text/javascript"> jQuery(document).ready(function($) { $("#foxyshop_searchform button").live("click", function() { if ($("#transaction_search_type option:selected").attr("target") == "_blank") { $("#foxyshop_searchform").attr("target","_blank"); } else { $("#foxyshop_searchform").attr("target","_self"); } }); $(".tablenav a.disabled").click(function() { return false; }); $(".foxyshop_date_field").datepicker({ dateFormat: 'yy-mm-dd' }); }); </script> <?php if (!isset($_GET['foxyshop_search']) && defined('FOXYSHOP_AUTO_API_DISABLED')) { return; } $foxy_response = foxyshop_get_foxycart_data($foxy_data); $xml = simplexml_load_string($foxy_response, NULL, LIBXML_NOCDATA); //var_dump($xml); if ((string) $xml->result == __('ERROR', 'foxyshop')) { echo '<h3>' . (string) $xml->messages->message . '</h3>'; return; } else { ?> <form action="edit.php" method="get"> <input type="hidden" name="foxyshop_search" value="1" /> <input type="hidden" name="post_type" value="foxyshop_product" /> <input type="hidden" name="page" value="foxyshop_order_management" /> <?php echo $foxyshop_hidden_input; foxyshop_api_paging_nav('transactions', 'top', $xml, $foxyshop_querystring); ?> <table cellpadding="0" cellspacing="0" border="0" class="wp-list-table widefat foxyshop-list-table" id="transaction_table"> <thead> <tr> <th id="cb" class="manage-column column-cb check-column" scope="col"><input type="checkbox"></th> <th><span><?php _e('Transaction ID', 'foxyshop'); ?> </span><span class="sorting-indicator"></span></th> <th><span><?php _e('Order Date', 'foxyshop'); ?> </span><span class="sorting-indicator"></span></th> <th><span><?php _e('Customer', 'foxyshop'); ?> </span><span class="sorting-indicator"></span></th> <th><span><?php _e('Total', 'foxyshop'); ?> </span><span class="sorting-indicator"></span></th> <?php do_action("foxyshop_order_table_head"); ?> </tr> </thead> <tfoot> <tr> <th class="manage-column column-cb check-column" style="" scope="col"><input type="checkbox"></th> <th><?php _e('Transaction ID', 'foxyshop'); ?> </th> <th><?php _e('OrderDate', 'foxyshop'); ?> </th> <th><?php _e('Customer', 'foxyshop'); ?> </th> <th><?php _e('Total', 'foxyshop'); ?> </th> <?php do_action("foxyshop_order_table_foot"); ?> </tr> </tfoot> <tbody id="the-list"> <?php $holder = ""; $hide_transaction_filter = isset($_REQUEST['hide_transaction_filter']) ? $_REQUEST['hide_transaction_filter'] : 0; foreach ($xml->transactions->transaction as $transaction) { $transaction_id = (string) $transaction->id; $customer_first_name = (string) $transaction->customer_first_name; $customer_last_name = (string) $transaction->customer_last_name; $is_anonymous = (int) $transaction->is_anonymous; $customer_id = (string) $transaction->customer_id; $minfraud_score = (int) $transaction->minfraud_score; $transaction_date = (string) $transaction->transaction_date; $transaction_date = date(apply_filters("foxyshop_date_time_format", "Y-m-d H:i"), strtotime($transaction_date)); $customer_name = $customer_last_name . ', ' . $customer_first_name; if ($is_anonymous != 1 && $customer_id) { $customer_name = '<a href="edit.php?post_type=foxyshop_product&page=foxyshop_customer_management&customer_id_filter=' . $customer_id . '&foxyshop_search=1" title="Customer ' . $customer_id . '">' . $customer_name . '</a>'; } $print_receipt_link = "edit.php?foxyshop_search=1&post_type=foxyshop_product&page=foxyshop_order_management&id_filter=" . $transaction_id . "&foxyshop_print_invoice=1&is_test_filter=&skip_print=1&transaction_date_filter_begin=" . $foxy_data['transaction_date_filter_begin'] . "&transaction_date_filter_end=" . $foxy_data['transaction_date_filter_end']; foreach ($transaction->transaction_details->transaction_detail as $transaction_detail) { $pickup_day = ""; $pickup_location = ""; foreach ($transaction_detail->transaction_detail_options->transaction_detail_option as $transaction_detail_option) { if ((string) $transaction_detail_option->product_option_name == "Pickup_Day") { $pickup_day = (string) $transaction_detail_option->product_option_value; } elseif ((string) $transaction_detail_option->product_option_name == "Pickup_Location") { $pickup_location = (string) $transaction_detail_option->product_option_value; } $holder .= '<li>'; $holder .= str_replace("_", " ", (string) $transaction_detail_option->product_option_name) . ': '; if (substr((string) $transaction_detail_option->product_option_value, 0, 5) == "file-") { $upload_dir = wp_upload_dir(); $holder .= '<a href="' . $upload_dir['baseurl'] . '/customuploads/' . (string) $transaction_detail_option->product_option_value . '" target="_blank">' . (string) $transaction_detail_option->product_option_value . '</a>'; } else { $holder .= $transaction_detail_option->product_option_value; } if ((string) $transaction_detail_option->price_mod != '0.000') { $holder .= ' (' . (strpos("-", $transaction_detail_option->price_mod) !== false ? '-' : '+') . foxyshop_currency((double) $transaction_detail_option->price_mod) . ')'; } $holder .= '</li>'; } } echo '<tr rel="' . $transaction_id . '">'; echo '<th class="check-column" scope="row"><input type="checkbox" value="' . $transaction_id . '" name="post[]"></th>' . "\n"; echo '<td>'; echo '<a href="' . (string) $transaction->receipt_url . '" title="' . __('FoxyCart Receipt', 'foxyshop') . '" target="_blank" style="float: left;"><img src="' . FOXYSHOP_DIR . '/images/foxycart-icon.png" alt="" align="top" /></a>'; echo '<strong><a href="#" class="view_detail" style="float: left; line-height: 18px; margin: 0 0 0 5px;">' . $transaction_id . '</a></strong>'; echo '<div class="row-actions">'; echo '<span><a href="#" class="view_detail">' . __('View Order', 'foxyshop') . '</a> | </span>'; echo '<span><a href="' . $print_receipt_link . '" title="' . __('Printable Receipt', 'foxyshop') . '" target="_blank">' . __('Receipt', 'foxyshop') . '</a></span>'; if (!isset($transaction->is_hidden)) { $is_hidden = $hide_transaction_filter; } else { $is_hidden = (string) $transaction->is_hidden; } if ($is_hidden == 1) { echo '<span> | <a href="#" class="set_order_hidden_status" rel="0">' . __('Un-Archive', 'foxyshop') . '</a></span>'; } else { echo '<span> | <a href="#" class="set_order_hidden_status" rel="1">' . __('Archive', 'foxyshop') . '</a></span>'; } do_action("foxyshop_order_line_item", $transaction); echo '</div>'; echo '</td>'; echo '<td>' . $transaction_date . '</td>'; echo '<td>' . $customer_name . '</td>'; echo '<td>' . foxyshop_currency((double) $transaction->order_total) . '</td>'; do_action("foxyshop_order_line_end", $transaction); echo '</tr>' . "\n"; //Write Out Order Details Holder $holder .= '<div class="detail_holder" id="holder_' . $transaction_id . '">' . "\n"; $holder .= '<div class="foxyshop_list_col">'; $holder .= '<h4>' . __('Transaction Details', 'foxyshop') . '</h4>'; $holder .= '<ul>'; $holder .= '<li>' . __('Order ID', 'foxyshop') . ': ' . (string) $transaction->id . '</li>'; $holder .= '<li>' . __('Date', 'foxyshop') . ': ' . $transaction_date . '</li>'; $holder .= '<li>' . (string) $transaction->processor_response . '</li>'; if ((string) $transaction->cc_number_masked != "") { $holder .= '<li>' . __('Card', 'foxyshop') . ': ' . (string) $transaction->cc_number_masked . ' (' . (string) $transaction->cc_type . ')</li>'; } if ((string) $transaction->cc_exp_month != "") { $holder .= '<li>' . __('Exp', 'foxyshop') . ': ' . (string) $transaction->cc_exp_month . '-' . (string) $transaction->cc_exp_year . '</li>'; } if ($minfraud_score > 0) { $holder .= '<li>' . __('MinFraud Score', 'foxyshop') . ': ' . $minfraud_score . '</li>'; } if ((string) $transaction->shipto_shipping_service_description != "") { $holder .= '<li>' . __('Shipping Type', 'foxyshop') . ': ' . (string) $transaction->shipto_shipping_service_description . '</li>'; } if ((string) $transaction->processor_response == "Purchase Order") { $holder .= '<li>PO #: ' . (string) $transaction->purchase_order . '</li>'; } $holder .= '</ul>'; $holder .= '</div>'; $holder .= '<div class="foxyshop_list_col">'; $holder .= '<h4>' . __('Order Details', 'foxyshop') . '</h4>'; $holder .= '<ul>'; $holder .= '<li>' . __('Subtotal', 'foxyshop') . ': ' . foxyshop_currency((double) $transaction->product_total) . '</li>'; //Discounts foreach ($transaction->discounts->discount as $discount) { $holder .= '<li>' . (string) $discount->name . ': ' . foxyshop_currency((double) $discount->amount) . '</li>'; } //Taxes foreach ($transaction->taxes->tax as $tax) { $holder .= '<li>' . (string) $tax->tax_name . ': ' . foxyshop_currency((double) $tax->tax_amount) . '</li>'; } $holder .= '<li>' . __('Shipping', 'foxyshop') . ': ' . foxyshop_currency((double) $transaction->shipping_total) . '</li>'; $holder .= '<li><strong>' . __('Order Total', 'foxyshop') . ': ' . foxyshop_currency((double) $transaction->order_total) . '</strong></li>'; $holder .= '</ul>'; $holder .= '</div>'; $holder .= '<div class="foxyshop_list_col">'; $holder .= '<h4>' . __('Customer Address', 'foxyshop') . '</h4>'; $holder .= '<ul>'; $holder .= '<li>' . (string) $transaction->customer_first_name . ' ' . (string) $transaction->customer_last_name . '</li>'; if ((string) $transaction->customer_company != "") { $holder .= '<li>' . (string) $transaction->customer_company . '</li>'; } $holder .= '<li>' . (string) $transaction->customer_address1 . '</li>'; if ((string) $transaction->customer_address2 != "") { $holder .= '<li>' . (string) $transaction->customer_address2 . '</li>'; } $holder .= '<li>' . (string) $transaction->customer_city . ', ' . (string) $transaction->customer_state . ' ' . (string) $transaction->customer_postal_code . '</li>'; $holder .= '<li>' . (string) $transaction->customer_country . '</li>'; $holder .= '</ul>'; $holder .= '</div>'; //Shipping Addresses (if entered) if ((string) $transaction->shipping_first_name != "" && !isset($transaction->shipto_addresses->shipto_address)) { $holder .= '<div class="foxyshop_list_col">'; $holder .= '<h4>' . __('Shipping Details', 'foxyshop') . '</h4>'; $holder .= '<ul>'; $holder .= '<li>' . (string) $transaction->shipping_first_name . ' ' . (string) $transaction->shipping_last_name . '</li>'; if ((string) $transaction->shipping_company != "") { $holder .= '<li>' . (string) $transaction->shipping_company . '</li>'; } $holder .= '<li>' . (string) $transaction->shipping_address1 . '</li>'; if ((string) $transaction->shipping_address2 != "") { $holder .= '<li>' . (string) $transaction->shipping_address2 . '</li>'; } $holder .= '<li>' . (string) $transaction->shipping_city . ', ' . (string) $transaction->shipping_state . ' ' . (string) $transaction->shipping_postal_code . '</li>'; $holder .= '<li>' . (string) $transaction->shipping_country . '</li>'; if ((string) $transaction->shipping_phone != "") { $holder .= '<li>' . (string) $transaction->shipping_phone . '</li>'; } $holder .= '</ul>'; $holder .= '</div>'; } //Multi-ship Addresses foreach ($transaction->shipto_addresses->shipto_address as $shipto_address) { $holder .= '<div class="foxyshop_list_col">'; $holder .= '<h4>' . __('Shipping Details', 'foxyshop') . ': ' . $shipto_address->address_name . '</h4>'; $holder .= '<ul>'; $holder .= '<li>' . $shipto_address->shipto_first_name . ' ' . $shipto_address->shipto_last_name . '</li>'; if ((string) $shipto_address->shipto_company != "") { $holder .= '<li>' . $shipto_address->shipto_company . '</li>'; } $holder .= '<li>' . $shipto_address->shipto_address1 . '</li>'; if ((string) $shipto_address->shipto_address2 != "") { $holder .= '<li>' . $shipto_address->shipto_address2 . '</li>'; } $holder .= '<li>' . $shipto_address->shipto_city . ', ' . $shipto_address->shipto_state . ' ' . $shipto_address->shipto_postal_code . '</li>'; $holder .= '<li>' . $shipto_address->shipto_country . '</li>'; if ((string) $shipto_address->shipto_phone != "") { $holder .= '<li>' . $shipto_address->shipto_phone . '</li>'; } $holder .= '<li><br />' . __('Method', 'foxyshop') . ': ' . $shipto_address->shipto_shipping_service_description . '</li>'; $holder .= '<li>' . __('Shipping', 'foxyshop') . ': ' . foxyshop_currency((double) $shipto_address->shipto_shipping_total) . '</li>'; $holder .= '</ul>'; $holder .= '</div>'; } //Customer Details $holder .= '<div class="foxyshop_list_col">'; $holder .= '<h4>' . __('Customer Details', 'foxyshop') . '</h4>'; $holder .= '<ul>'; if ((string) $transaction->customer_phone != "") { $holder .= '<li>' . (string) $transaction->customer_phone . '</li>'; } $holder .= '<li><a href="mailto:' . (string) $transaction->customer_email . '">' . (string) $transaction->customer_email . '</a></li>'; $holder .= '<li>' . apply_filters('foxyshop_order_ip', '<a href="http://whatismyipaddress.com/ip/' . (string) $transaction->customer_ip . '" target="_blank">' . (string) $transaction->customer_ip . '</a>', (string) $transaction->customer_ip) . '</li>'; $holder .= '<li> </li>'; //Custom Fields foreach ($transaction->custom_fields->custom_field as $custom_field) { if ($custom_field->custom_field_name != 'ga') { $holder .= '<li><strong>' . str_replace("_", " ", (string) $custom_field->custom_field_name) . ':</strong> ' . nl2br((string) $custom_field->custom_field_value) . '</li>'; } } $holder .= '</ul>'; $holder .= '</div>'; //Custom Attributes $holder .= foxyshop_manage_attributes($transaction->attributes, $transaction_id, "transaction"); $holder .= '<div style="clear: both; height: 20px;"></div>'; foreach ($transaction->transaction_details->transaction_detail as $transaction_detail) { $holder .= '<div class="product_listing">'; if ($transaction_detail->image != "") { $holder .= '<div class="image_div">'; if ($transaction_detail->url != "") { $holder .= '<a href="' . $transaction_detail->url . '" target="_blank">'; } $holder .= '<img src="' . $transaction_detail->image . '" />'; if ($transaction_detail->url != "") { $holder .= '</a>'; } $holder .= '</div>'; } $product_discount = 0; $weight_discount = 0; foreach ($transaction_detail->transaction_detail_options->transaction_detail_option as $transaction_detail_option) { $product_discount += (double) $transaction_detail_option->price_mod; $weight_discount += (double) $transaction_detail_option->weight_mod; } $holder .= '<div class="details_div">'; $holder .= '<h4>' . $transaction_detail->product_name . '</h4>'; $holder .= '<ul>'; if ((string) $transaction_detail->shipto != "") { $holder .= '<li>Ship To: ' . (string) $transaction_detail->shipto . '</li>'; } $holder .= '<li>' . __('Code', 'foxyshop') . ': ' . (string) $transaction_detail->product_code . '</li>'; $holder .= '<li>' . __('Price', 'foxyshop') . ': ' . foxyshop_currency((double) $transaction_detail->product_price) . '</li>'; if ($product_discount != 0) { $holder .= '<li>Adjusted Price: ' . foxyshop_currency((double) $transaction_detail->product_price + $product_discount) . '</li>'; } $holder .= '<li>' . __('Qty', 'foxyshop') . ': ' . $transaction_detail->product_quantity . '</li>'; if ((string) $transaction_detail->product_weight != "0.000") { $holder .= '<li>Weight: ' . (string) $transaction_detail->product_weight . '</li>'; } if ($weight_discount != 0) { $holder .= '<li>Adjusted Weight: ' . ((double) $transaction_detail->product_weight + $weight_discount) . '</li>'; } if ((string) $transaction_detail->category_code != "DEFAULT") { $holder .= '<li>Category: ' . (string) $transaction_detail->category_description . '</li>'; } if ((string) $transaction_detail->product_delivery_type != "shipped") { $holder .= '<li>Delivery Type: ' . (string) $transaction_detail->product_delivery_type . '</li>'; } if ((string) $transaction_detail->downloadable_url != "") { $holder .= '<li>Downloadable URL: <a href="' . (string) $transaction_detail->downloadable_url . '" target="_blank">Click Here</a></li>'; } if ($transaction_detail->subscription_frequency != "") { $holder .= '<li>' . __('Subscription Frequency', 'foxyshop') . ': ' . (string) $transaction_detail->subscription_frequency . '</li>'; $holder .= '<li>' . __('Subscription Start Date', 'foxyshop') . ': ' . (string) $transaction_detail->subscription_startdate . '</li>'; $holder .= '<li>' . __('Subscription Next Date', 'foxyshop') . ': ' . (string) $transaction_detail->subscription_nextdate . '</li>'; if ((string) $transaction_detail->subscription_enddate != "0000-00-00") { $holder .= '<li>Subscription End Date: ' . (string) $transaction_detail->subscription_enddate . '</li>'; } } foreach ($transaction_detail->transaction_detail_options->transaction_detail_option as $transaction_detail_option) { $holder .= '<li>'; $holder .= str_replace("_", " ", (string) $transaction_detail_option->product_option_name) . ': '; if (substr((string) $transaction_detail_option->product_option_value, 0, 5) == "file-") { $upload_dir = wp_upload_dir(); $holder .= '<a href="' . $upload_dir['baseurl'] . '/customuploads/' . (string) $transaction_detail_option->product_option_value . '" target="_blank">' . (string) $transaction_detail_option->product_option_value . '</a>'; } else { $holder .= $transaction_detail_option->product_option_value; } if ((string) $transaction_detail_option->price_mod != '0.000') { $holder .= ' (' . (strpos("-", $transaction_detail_option->price_mod) !== false ? '-' : '+') . foxyshop_currency((double) $transaction_detail_option->price_mod) . ')'; } $holder .= '</li>'; } $holder .= '</ul>'; $holder .= '</div>'; $holder .= '<div style="clear: both;"></div>'; $holder .= '</div>'; } $holder .= '<div style="clear: both; height: 10px;"></div>'; $holder .= '</div>'; } echo '</tbody></table>'; foxyshop_api_paging_nav('transactions', 'bottom', $xml, $foxyshop_querystring); ?> </form> <?php } ?> <div id="details_holder"><?php echo $holder; ?> </div> <script type="text/javascript" src="<?php echo FOXYSHOP_DIR; ?> /js/jquery.tablesorter.js"></script> <script type="text/javascript"> jQuery(document).ready(function($){ $(".foxyshop-list-table thead th").click(function() { $("#foxyshop-list-inline .detail_holder").appendTo("#details_holder"); $("#foxyshop-list-inline").remove(); }); $(".foxyshop-list-table").tablesorter({ 'cssDesc': 'asc sorted', 'cssAsc': 'desc sorted', 'headers': { 0: { sorter: false} } }); $(".view_detail").click(function() { var id = $(this).parents("tr").attr("rel"); if ($("#foxyshop-list-inline #holder_" + id).length > 0) { $("#foxyshop-list-inline .detail_holder").appendTo("#details_holder"); $("#foxyshop-list-inline").remove(); } else { $("#foxyshop-list-inline .detail_holder").appendTo("#details_holder"); $("#foxyshop-list-inline").remove(); $(this).parents("tr").after('<tr id="foxyshop-list-inline"><td colspan="7"></td></tr>'); $("#holder_"+id).appendTo("#foxyshop-list-inline td"); } return false; }); $(".set_order_hidden_status").click( function() { var hide_transaction = $(this).attr("rel"); var transaction_id = $(this).parents("tr").attr("rel"); var data = { action: 'foxyshop_display_list_ajax_action', security: '<?php echo wp_create_nonce("foxyshop-display-list-function"); ?> ', hide_transaction: hide_transaction, foxyshop_action: 'hide_transaction', id: transaction_id }; $.post(ajaxurl, data, function(response) { <?php if ($hide_transaction_filter == "0") { ?> $("tr[rel="+transaction_id+"]").remove(); $("#foxyshop-list-inline #holder_" + transaction_id).remove(); <?php } else { ?> alert(response); <?php } ?> }); return false; }); <?php foxyshop_manage_attributes_jquery('transaction'); ?> }); </script> <?php }