/** * wpmlm_change_tax function, used through ajax and in normal page loading. * No parameters, returns nothing */ function wpmlm_change_tax() { global $wpdb, $wpmlm_cart; $form_id = absint($_POST['form_id']); $wpmlm_selected_country = $wpmlm_cart->selected_country; $wpmlm_selected_region = $wpmlm_cart->selected_region; $wpmlm_delivery_country = $wpmlm_cart->delivery_country; $wpmlm_delivery_region = $wpmlm_cart->delivery_region; $previous_country = $_SESSION['wpmlm_selected_country']; if (isset($_POST['billing_country'])) { $wpmlm_selected_country = $_POST['billing_country']; $_SESSION['wpmlm_selected_country'] = $wpmlm_selected_country; } if (isset($_POST['billing_region'])) { $wpmlm_selected_region = absint($_POST['billing_region']); $_SESSION['wpmlm_selected_region'] = $wpmlm_selected_region; } $check_country_code = $wpdb->get_var($wpdb->prepare("SELECT `country`.`isocode` FROM `" . WPMLM_TABLE_REGION_TAX . "` AS `region` INNER JOIN `" . WPMLM_TABLE_CURRENCY_LIST . "` AS `country` ON `region`.`country_id` = `country`.`id` WHERE `region`.`id` = %d LIMIT 1", $_SESSION['wpmlm_selected_region'])); if ($_SESSION['wpmlm_selected_country'] != $check_country_code) { $wpmlm_selected_region = null; } if (isset($_POST['shipping_country'])) { $wpmlm_delivery_country = $_POST['shipping_country']; $_SESSION['wpmlm_delivery_country'] = $wpmlm_delivery_country; } if (isset($_POST['shipping_region'])) { $wpmlm_delivery_region = absint($_POST['shipping_region']); $_SESSION['wpmlm_delivery_region'] = $wpmlm_delivery_region; } $check_country_code = $wpdb->get_var($wpdb->prepare("SELECT `country`.`isocode` FROM `" . WPMLM_TABLE_REGION_TAX . "` AS `region` INNER JOIN `" . WPMLM_TABLE_CURRENCY_LIST . "` AS `country` ON `region`.`country_id` = `country`.`id` WHERE `region`.`id` = %d LIMIT 1", $wpmlm_delivery_region)); if ($wpmlm_delivery_country != $check_country_code) { $wpmlm_delivery_region = null; } $wpmlm_cart->update_location(); $wpmlm_cart->get_shipping_method(); $wpmlm_cart->get_shipping_option(); if ($wpmlm_cart->selected_shipping_method != '') { $wpmlm_cart->update_shipping($wpmlm_cart->selected_shipping_method, $wpmlm_cart->selected_shipping_option); } $tax = $wpmlm_cart->calculate_total_tax(); $total = wpmlm_cart_total(); $total_input = wpmlm_cart_total(false); if ($wpmlm_cart->coupons_amount >= wpmlm_cart_total(false) && !empty($wpmlm_cart->coupons_amount)) { $total = 0; } if ($wpmlm_cart->total_price < 0) { $wpmlm_cart->coupons_amount += $wpmlm_cart->total_price; $wpmlm_cart->total_price = null; $wpmlm_cart->calculate_total_price(); } ob_start(); include_once wpmlm_get_template_file_path('wpmlm-cart_widget.php'); $output = ob_get_contents(); ob_end_clean(); $output = str_replace(array("\n", "\r"), array("\\n", "\\r"), addslashes($output)); if (get_option('lock_tax') == 1) { echo "jQuery('#current_country').val('" . esc_js($_SESSION['wpmlm_delivery_country']) . "'); \n"; if ($_SESSION['wpmlm_delivery_country'] == 'US' && get_option('lock_tax') == 1) { $output = wpmlm_shipping_region_list($_SESSION['wpmlm_delivery_country'], $_SESSION['wpmlm_delivery_region']); $output = str_replace(array("\n", "\r"), array("\\n", "\\r"), addslashes($output)); echo "jQuery('#region').remove();\n\r"; echo "jQuery('#change_country').append(\"" . $output . "\");\n\r"; } } foreach ($wpmlm_cart->cart_items as $key => $cart_item) { echo "jQuery('#shipping_{$key}').html(\"" . wpmlm_currency_display($cart_item->shipping) . "\");\n\r"; } echo "jQuery('#checkout_shipping').html(\"" . wpmlm_cart_shipping() . "\");\n\r"; echo "jQuery('div.shopping-cart-wrapper').html('{$output}');\n"; if (get_option('lock_tax') == 1) { echo "jQuery('.shipping_country').val('" . esc_js($_SESSION['wpmlm_delivery_country']) . "') \n"; $sql = $wpdb->prepare("SELECT `country` FROM `" . WPMLM_TABLE_CURRENCY_LIST . "` WHERE `isocode`= '%s'", $_SESSION['wpmlm_selected_country']); $country_name = $wpdb->get_var($sql); echo "jQuery('.shipping_country_name').html('" . $country_name . "') \n"; } $form_selected_country = null; $form_selected_region = null; $onchange_function = null; if (!empty($_POST['billing_country']) && $_POST['billing_country'] != 'undefined' && !isset($_POST['shipping_country'])) { $form_selected_country = $wpmlm_selected_country; $form_selected_region = $wpmlm_selected_region; $onchange_function = 'set_billing_country'; } else { if (!empty($_POST['shipping_country']) && $_POST['shipping_country'] != 'undefined' && !isset($_POST['billing_country'])) { $form_selected_country = $wpmlm_delivery_country; $form_selected_region = $wpmlm_delivery_region; $onchange_function = 'set_shipping_country'; } } if ($form_selected_country != null && $onchange_function != null) { $region_list = $wpdb->get_results($wpdb->prepare("SELECT `" . WPMLM_TABLE_REGION_TAX . "`.* FROM `" . WPMLM_TABLE_REGION_TAX . "`, `" . WPMLM_TABLE_CURRENCY_LIST . "` WHERE `" . WPMLM_TABLE_CURRENCY_LIST . "`.`isocode` IN('%s') AND `" . WPMLM_TABLE_CURRENCY_LIST . "`.`id` = `" . WPMLM_TABLE_REGION_TAX . "`.`country_id`", $form_selected_country), ARRAY_A); if ($region_list != null) { $title = empty($_POST['billing_country']) ? 'shippingstate' : 'billingstate'; $output = "<select name='collected_data[" . $form_id . "][1]' class='current_region' onchange='{$onchange_function}(\"region_country_form_{$form_id}\", \"{$form_id}\");' title='" . $title . "'>\n\r"; foreach ($region_list as $region) { if ($form_selected_region == $region['id']) { $selected = "selected='selected'"; } else { $selected = ""; } $output .= " <option value='" . $region['id'] . "' {$selected}>" . htmlspecialchars($region['name']) . "</option>\n\r"; } $output .= "</select>\n\r"; $output = str_replace(array("\n", "\r"), array("\\n", "\\r"), addslashes($output)); echo "jQuery('#region_select_{$form_id}').html(\"" . $output . "\");\n\r"; echo "\n\t\t\t\tvar wpmlm_checkout_table_selector = jQuery('#region_select_{$form_id}').parents('.wpmlm_checkout_table').attr('class');\n\t\t\t\twpmlm_checkout_table_selector = wpmlm_checkout_table_selector.replace(' ','.');\n\t\t\t\twpmlm_checkout_table_selector = '.'+wpmlm_checkout_table_selector;\n\t\t\t\tjQuery(wpmlm_checkout_table_selector + ' input.billing_region').attr('disabled', 'disabled');\n\t\t\t\tjQuery(wpmlm_checkout_table_selector + ' input.shipping_region').attr('disabled', 'disabled');\n\t\t\t\tjQuery(wpmlm_checkout_table_selector + ' .billing_region').parent().parent().hide();\n\t\t\t\tjQuery(wpmlm_checkout_table_selector + ' .shipping_region').parent().parent().hide();\n\t\t\t"; } else { if (get_option('lock_tax') == 1) { echo "jQuery('#region').hide();"; } echo "jQuery('#region_select_{$form_id}').html('');\n\r"; echo "\n\t\t\t\tvar wpmlm_checkout_table_selector = jQuery('#region_select_{$form_id}').parents('.wpmlm_checkout_table').attr('class');\n\t\t\t\twpmlm_checkout_table_selector = wpmlm_checkout_table_selector.replace(' ','.');\n\t\t\t\twpmlm_checkout_table_selector = '.'+wpmlm_checkout_table_selector;\n\t\t\t\tjQuery(wpmlm_checkout_table_selector + ' input.billing_region').removeAttr('disabled');\n\t\t\t\tjQuery(wpmlm_checkout_table_selector + ' input.shipping_region').removeAttr('disabled');\n\t\t\t\tjQuery(wpmlm_checkout_table_selector + ' .billing_region').parent().parent().show();\n\t\t\t\tjQuery(wpmlm_checkout_table_selector + ' .shipping_region').parent().parent().show();\n\t\t\t"; } } if ($tax > 0) { echo "jQuery(\"tr.total_tax\").show();\n\r"; } else { echo "jQuery(\"tr.total_tax\").hide();\n\r"; } echo "jQuery('#checkout_tax').html(\"<span class='pricedisplay'>" . wpmlm_cart_tax() . "</span>\");\n\r"; echo "jQuery('#checkout_total').html(\"{$total}<input id='shopping_cart_total_price' type='hidden' value='{$total_input}' />\");\n\r"; exit; }
function wpmlm_also_bought($product_id) { /* * Displays products that were bought aling with the product defined by $product_id * most of it scarcely needs describing */ global $wpdb; if (get_option('wpmlm_also_bought') == 0) { //returns nothing if this is off return ''; } // to be made customiseable in a future release $also_bought_limit = 3; $element_widths = 96; $image_display_height = 96; $image_display_width = 96; $output = ''; $also_bought = $wpdb->get_results($wpdb->prepare("SELECT `" . $wpdb->posts . "`.* FROM `" . WPMLM_TABLE_ALSO_BOUGHT . "`, `" . $wpdb->posts . "` WHERE `selected_product`= %d AND `" . WPMLM_TABLE_ALSO_BOUGHT . "`.`associated_product` = `" . $wpdb->posts . "`.`id` AND `" . $wpdb->posts . "`.`post_status` IN('publish','protected') ORDER BY `" . WPMLM_TABLE_ALSO_BOUGHT . "`.`quantity` DESC LIMIT {$also_bought_limit}", $product_id), ARRAY_A); if (count($also_bought) > 0) { $output .= "<h2 class='prodtitles wpmlm_also_bought' >" . __('People who bought this item also bought', 'wpmlm') . "</h2>"; $output .= "<div class='wpmlm_also_bought'>"; foreach ((array) $also_bought as $also_bought_data) { $output .= "<div class='wpmlm_also_bought_item' style='width: " . $element_widths . "px;'>"; if (get_option('show_thumbnails') == 1) { $image_path = wpmlm_the_product_thumbnail($image_display_width, $image_display_height, $also_bought_data['ID']); if ($image_path) { $output .= "<a href='" . get_permalink($also_bought_data['ID']) . "' class='preview_link' rel='" . str_replace(" ", "_", get_the_title($also_bought_data['ID'])) . "'>"; $image_path = "index.php?productid=" . $also_bought_data['ID'] . "&width=" . $image_display_width . "&height=" . $image_display_height . ""; $output .= "<img src='{$image_path}' id='product_image_" . $also_bought_data['ID'] . "' class='product_image' style='margin-top: " . $margin_top . "px'/>"; $output .= "</a>"; } else { if (get_option('product_image_width') != '') { $output .= "<img src='" . WPMLM_CORE_IMAGES_URL . "/no-image-uploaded.gif' title='" . get_the_title($also_bought_data['ID']) . "' alt='" . $also_bought_data['name'] . "' width='{$image_display_height}' height='{$image_display_height}' id='product_image_" . $also_bought_data['ID'] . "' class='product_image' />"; } else { $output .= "<img src='" . WPMLM_CORE_IMAGES_URL . "/no-image-uploaded.gif' title='" . get_the_title($also_bought_data['ID']) . "' alt='" . htmlentities(stripslashes(get_the_title($also_bought_data['ID'])), ENT_QUOTES, 'UTF-8') . "' id='product_image_" . $also_bought_data['ID'] . "' class='product_image' />"; } } } $output .= "<a class='wpmlm_product_name' href='" . get_permalink($also_bought_data['ID']) . "'>" . get_the_title($also_bought_data['ID']) . "</a>"; $price = get_product_meta($also_bought_data['ID'], 'price', true); $special_price = get_product_meta($also_bought_data['ID'], 'special_price', true); if (!empty($special_price)) { $output .= '<span style="text-decoration: line-through;">' . wpmlm_currency_display($price) . '</span>'; $output .= wpmlm_currency_display($special_price); } else { $output .= wpmlm_currency_display($price); } $output .= "</div>"; } $output .= "</div>"; $output .= "<br clear='all' />"; } return $output; }
/** * wpmlm_ajax_ie_save save changes made using inline edit * * @public * * @3.8 * @returns nothing */ function wpmlm_ajax_ie_save() { $product_post_type = get_post_type_object('wpmlm-product'); if (!current_user_can($product_post_type->cap->edit_posts)) { echo '({"error":"' . __('Error: you don\'t have required permissions to edit this product', 'wpmlm') . '", "id": "' . esc_js($_POST['id']) . '"})'; die; } $id = absint($_POST['id']); $post = get_post($_POST['id']); $parent = get_post($post->post_parent); $terms = wp_get_object_terms($id, 'wpmlm-variation', array('fields' => 'names')); $product = array('ID' => $_POST['id'], 'post_title' => $parent->post_title . ' (' . implode(', ', $terms) . ')'); $id = wp_update_post($product); if ($id > 0) { //need parent meta to know which weight unit we are using $parent_meta = get_product_meta($post->post_parent, 'product_metadata', true); $product_meta = get_product_meta($product['ID'], 'product_metadata', true); if (is_numeric($_POST['weight']) || empty($_POST['weight'])) { $product_meta['weight'] = wpmlm_convert_weight($_POST['weight'], $parent_meta['weight_unit'], 'pound', true); $product_meta['weight_unit'] = $parent_meta['weight_unit']; } update_product_meta($product['ID'], 'product_metadata', $product_meta); update_product_meta($product['ID'], 'price', (double) $_POST['price']); update_product_meta($product['ID'], 'special_price', (double) $_POST['special_price']); update_product_meta($product['ID'], 'sku', $_POST['sku']); if (!is_numeric($_POST['stock'])) { update_product_meta($product['ID'], 'stock', ''); } else { update_product_meta($product['ID'], 'stock', absint($_POST['stock'])); } $meta = get_product_meta($id, 'product_metadata', true); $price = get_product_meta($id, 'price', true); $special_price = get_product_meta($id, 'special_price', true); $sku = get_product_meta($id, 'sku', true); $sku = $sku ? $sku : __('N/A', 'wpmlm'); $stock = get_product_meta($id, 'stock', true); $stock = $stock === '' ? __('N/A', 'wpmlm') : $stock; $results = array('id' => $id, 'title' => $post->post_title, 'weight' => wpmlm_convert_weight($meta['weight'], 'pound', $parent_meta['weight_unit']), 'price' => wpmlm_currency_display($price), 'special_price' => wpmlm_currency_display($special_price), 'sku' => $sku, 'stock' => $stock); echo '(' . json_encode($results) . ')'; die; } else { echo '({"error":"' . __('Error updating product', 'wpmlm') . '", "id": "' . esc_js($_POST['id']) . '"})'; } die; }
function wpmlm_packing_slip($purchase_id) { echo "<!DOCTYPE html><html><head><title>" . __('Packing Slip', 'wpmlm') . "</title></head><body id='wpmlm-packing-slip'>"; global $wpdb; $purch_sql = $wpdb->prepare("SELECT * FROM `" . WPMLM_TABLE_PURCHASE_LOGS . "` WHERE `id`=%d", $purchase_id); $purch_data = $wpdb->get_row($purch_sql, ARRAY_A); $cartsql = $wpdb->prepare("SELECT * FROM `" . WPMLM_TABLE_CART_CONTENTS . "` WHERE `purchaseid`=%d", $purchase_id); $cart_log = $wpdb->get_results($cartsql, ARRAY_A); $j = 0; if ($cart_log != null) { echo "<div class='packing_slip'>\n\r"; echo apply_filters('wpmlm_packing_slip_header', '<h2>' . __('Packing Slip', 'wpmlm') . "</h2>\n\r"); echo "<strong>" . __('Order', 'wpmlm') . " #</strong> " . $purchase_id . "<br /><br />\n\r"; echo "<table>\n\r"; $form_sql = $wpdb->prepare("SELECT * FROM `" . WPMLM_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id` = %d", $purchase_id); $input_data = $wpdb->get_results($form_sql, ARRAY_A); foreach ($input_data as $input_row) { $rekeyed_input[$input_row['form_id']] = $input_row; } if ($input_data != null) { $form_data = $wpdb->get_results("SELECT * FROM `" . WPMLM_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1'", ARRAY_A); foreach ($form_data as $form_field) { switch ($form_field['type']) { case 'country': $region_count_sql = $wpdb->prepare("SELECT COUNT(`regions`.`id`) FROM `" . WPMLM_TABLE_REGION_TAX . "` AS `regions` INNER JOIN `" . WPMLM_TABLE_CURRENCY_LIST . "` AS `country` ON `country`.`id` = `regions`.`country_id` WHERE `country`.`isocode` IN('%s')", $purch_data['billing_country']); $delivery_region_count = $wpdb->get_var($region_count_sql); if (is_numeric($purch_data['billing_region']) && $delivery_region_count > 0) { echo "\t<tr><td>" . __('State', 'wpmlm') . ":</td><td>" . wpmlm_get_region($purch_data['billing_region']) . "</td></tr>\n\r"; } echo "\t<tr><td>" . wp_kses($form_field['name'], array()) . ":</td><td>" . htmlentities(stripslashes($rekeyed_input[$form_field['id']]['value']), ENT_QUOTES, 'UTF-8') . "</td></tr>\n\r"; break; case 'delivery_country': if (is_numeric($purch_data['shipping_region']) && $delivery_region_count > 0) { echo "\t<tr><td>" . __('State', 'wpmlm') . ":</td><td>" . wpmlm_get_region($purch_data['shipping_region']) . "</td></tr>\n\r"; } echo "\t<tr><td>" . wp_kses($form_field['name'], array()) . ":</td><td>" . htmlentities(stripslashes($rekeyed_input[$form_field['id']]['value']), ENT_QUOTES, 'UTF-8') . "</td></tr>\n\r"; break; case 'heading': if ($form_field['name'] == "Hidden Fields") { continue; } else { echo "\t<tr class='heading'><td colspan='2'><strong>" . wp_kses($form_field['name'], array()) . ":</strong></td></tr>\n\r"; } break; default: if ($form_field['name'] == "Cupcakes") { parse_str($rekeyed_input[$form_field['id']]['value'], $cupcakes); foreach ($cupcakes as $product_id => $quantity) { $product = get_post($product_id); $string .= "(" . $quantity . ") " . $product->post_title . ", "; } $string = rtrim($string, ", "); echo "\t<tr><td>" . wp_kses($form_field['name'], array()) . ":</td><td>" . htmlentities(stripslashes($string), ENT_QUOTES, 'UTF-8') . "</td></tr>\n\r"; } else { if ($form_field['name'] == "State" && !empty($purch_data['billing_region']) || $form_field['name'] == "State" && !empty($purch_data['billing_region'])) { echo ""; } else { echo "\t<tr><td>" . wp_kses($form_field['name'], array()) . ":</td><td>" . (isset($rekeyed_input[$form_field['id']]) ? htmlentities(stripslashes($rekeyed_input[$form_field['id']]['value']), ENT_QUOTES, 'UTF-8') : '') . "</td></tr>\n\r"; } } break; } } } else { echo "\t<tr><td>" . __('Name', 'wpmlm') . ":</td><td>" . $purch_data['firstname'] . " " . $purch_data['lastname'] . "</td></tr>\n\r"; echo "\t<tr><td>" . __('Address', 'wpmlm') . ":</td><td>" . $purch_data['address'] . "</td></tr>\n\r"; echo "\t<tr><td>" . __('Phone', 'wpmlm') . ":</td><td>" . $purch_data['phone'] . "</td></tr>\n\r"; echo "\t<tr><td>" . __('Email', 'wpmlm') . ":</td><td>" . $purch_data['email'] . "</td></tr>\n\r"; } if (2 == get_option('payment_method')) { $gateway_name = ''; $nzshpcrt_gateways = nzshpcrt_get_gateways(); foreach ($nzshpcrt_gateways as $gateway) { if ($purch_data['gateway'] != 'testmode') { if ($gateway['internalname'] == $purch_data['gateway']) { $gateway_name = $gateway['name']; } } else { $gateway_name = __('Manual Payment', 'wpmlm'); } } } echo "</table>\n\r"; do_action('wpmlm_packing_slip_extra_info', $purchase_id); echo "<table class='packing_slip'>"; echo "<tr>"; echo " <th>" . __('Quantity', 'wpmlm') . " </th>"; echo " <th>" . __('Name', 'wpmlm') . "</th>"; echo " <th>" . __('Price', 'wpmlm') . " </th>"; echo " <th>" . __('Shipping', 'wpmlm') . " </th>"; echo '<th>' . __('Tax', 'wpmlm') . '</th>'; echo '</tr>'; $endtotal = 0; $all_donations = true; $all_no_shipping = true; $file_link_list = array(); $total_shipping = 0; foreach ($cart_log as $cart_row) { $alternate = ""; $j++; if ($j % 2 != 0) { $alternate = "class='alt'"; } // product ID will be $cart_row['prodid']. need to fetch name and stuff $variation_list = ''; if ($cart_row['donation'] != 1) { $all_donations = false; } if ($cart_row['no_shipping'] != 1) { $shipping = $cart_row['pnp']; $total_shipping += $shipping; $all_no_shipping = false; } else { $shipping = 0; } $price = $cart_row['price'] * $cart_row['quantity']; $gst = $price - $price / (1 + $cart_row['gst'] / 100); if ($gst > 0) { $tax_per_item = $gst / $cart_row['quantity']; } echo "<tr {$alternate}>"; echo " <td>"; echo $cart_row['quantity']; echo " </td>"; echo " <td>"; echo $cart_row['name']; echo stripslashes($variation_list); echo " </td>"; echo " <td>"; echo wpmlm_currency_display($price); echo " </td>"; echo " <td>"; echo wpmlm_currency_display($shipping); echo " </td>"; echo '<td>'; echo wpmlm_currency_display($cart_row['tax_charged']); echo '</td>'; echo '</tr>'; } echo "</table>"; echo '<table class="packing-slip-totals">'; if (floatval($purch_data['discount_value'])) { echo '<tr><th>' . __('Discount', 'wpmlm') . '</th><td>(' . wpmlm_currency_display($purch_data['discount_value']) . ')</td></tr>'; } echo '<tr><th>' . __('Base Shipping', 'wpmlm') . '</th><td>' . wpmlm_currency_display($purch_data['base_shipping']) . '</td></tr>'; echo '<tr><th>' . __('Total Shipping', 'wpmlm') . '</th><td>' . wpmlm_currency_display($purch_data['base_shipping'] + $total_shipping) . '</td></tr>'; //wpec_taxes if ($purch_data['wpec_taxes_total'] != 0.0) { echo '<tr><th>' . __('Taxes', 'wpmlm') . '</th><td>' . wpmlm_currency_display($purch_data['wpec_taxes_total']) . '</td></tr>'; } echo '<tr><th>' . __('Total Price', 'wpmlm') . '</th><td>' . wpmlm_currency_display($purch_data['totalprice']) . '</td></tr>'; echo '</table>'; echo "</div>\n\r"; } else { echo "<br />" . __('This users cart was empty', 'wpmlm'); } }
function wpmlm_admin_ajax() { global $wpdb; if (isset($_POST['action']) && $_POST['action'] == 'product-page-order') { $current_order = get_option('wpmlm_product_page_order'); $new_order = $_POST['order']; if (isset($new_order["advanced"])) { $current_order["advanced"] = array_unique(explode(',', $new_order["advanced"])); } if (isset($new_order["side"])) { $current_order["side"] = array_unique(explode(',', $new_order["side"])); } update_option('wpmlm_product_page_order', $current_order); exit(print_r($order, 1)); } if (isset($_POST['save_image_upload_state']) && $_POST['save_image_upload_state'] == 'true' && is_numeric($_POST['image_upload_state'])) { $upload_state = (int) (bool) $_POST['image_upload_state']; update_option('wpmlm_use_flash_uploader', $upload_state); exit("done"); } if (isset($_POST['remove_variation_value']) && $_POST['remove_variation_value'] == "true" && is_numeric($_POST['variation_value_id'])) { $value_id = absint($_GET['variation_value_id']); echo wp_delete_term($value_id, 'wpmlm-variation'); exit; } if (isset($_POST['hide_ecom_dashboard']) && $_POST['hide_ecom_dashboard'] == 'true') { require_once ABSPATH . WPINC . '/rss.php'; $rss = fetch_rss('http://www.instinct.co.nz/feed/'); $rss->items = array_slice($rss->items, 0, 5); $rss_hash = sha1(serialize($rss->items)); update_option('wpmlm_ecom_news_hash', $rss_hash); exit(1); } if (isset($_POST['remove_meta']) && $_POST['remove_meta'] == 'true' && is_numeric($_POST['meta_id'])) { $meta_id = (int) $_POST['meta_id']; if (delete_meta($meta_id)) { echo $meta_id; exit; } echo 0; exit; } if (isset($_REQUEST['log_state']) && $_REQUEST['log_state'] == "true" && is_numeric($_POST['id']) && is_numeric($_POST['value'])) { $newvalue = $_POST['value']; if ($_REQUEST['suspend'] == 'true') { if ($_REQUEST['value'] == 1 && function_exists('wpmlm_member_dedeactivate_subscriptions')) { wpmlm_member_dedeactivate_subscriptions($_POST['id']); } elseif (function_exists('wpmlm_member_deactivate_subscriptions')) { wpmlm_member_deactivate_subscriptions($_POST['id']); } exit; } else { $log_data = $wpdb->get_row($wpdb->prepare("SELECT * FROM `" . WPMLM_TABLE_PURCHASE_LOGS . "` WHERE `id` = '%d' LIMIT 1", $_POST['id']), ARRAY_A); if ($newvalue == 2 && function_exists('wpmlm_member_activate_subscriptions')) { wpmlm_member_activate_subscriptions($_POST['id']); } $wpdb->update(WPMLM_TABLE_PURCHASE_LOGS, array('processed' => $newvalue), array('id' => $_POST['id']), '%d', '%d'); if ($newvalue > $log_data['processed'] && $log_data['processed'] < 2) { transaction_results($log_data['sessionid'], false); } $status_name = wpmlm_find_purchlog_status_name($purchase['processed']); echo "document.getElementById(\"form_group_" . absint($_POST['id']) . "_text\").innerHTML = '" . $status_name . "';\n"; $year = date("Y"); $month = date("m"); $start_timestamp = mktime(0, 0, 0, $month, 1, $year); $end_timestamp = mktime(0, 0, 0, $month + 1, 0, $year); echo "document.getElementById(\"log_total_month\").innerHTML = '" . addslashes(wpmlm_currency_display(admin_display_total_price($start_timestamp, $end_timestamp))) . "';\n"; echo "document.getElementById(\"log_total_absolute\").innerHTML = '" . addslashes(wpmlm_currency_display(admin_display_total_price())) . "';\n"; exit; } } }