$rule) { foreach ($rule as $k => $r) { $new_rule[$k][$key] = $r; } } foreach($new_rule as $key => $rule) { if ($rule['value'] == '') { unset($new_rule[$key]); } } if($wpdb->query("INSERT INTO `".WPSC_TABLE_COUPON_CODES."` ( `coupon_code` , `value` , `is-percentage` , `use-once` , `is-used` , `active` , `every_product` , `start` , `expiry`, `condition` ) VALUES ( '$coupon_code', '$discount', '$discount_type', '$use_once', '0', '1', '$every_product', '$start_date' , '$end_date' , '".serialize($new_rule)."' );")) { echo "
".__('Thanks, the coupon has been added.', 'wpsc')."
'.print_r($_POST, true).''); foreach((array)$_POST['edit_coupon'] as $coupon_id => $coupon_data) { //echo('
'.print_r($coupon_data,true).""); $coupon_id = (int)$coupon_id; // convert dates to a form that compares well and can be inserted into the database // $coupon_data['start'] = date("Y-m-d H:i:s", mktime(0, 0, 0, (int)$coupon_data['start']['month'], (int)$coupon_data['start']['day'], (int)$coupon_data['start']['year'])); // $coupon_data['expiry'] = date("Y-m-d H:i:s", mktime(0, 0, 0, (int)$coupon_data['expiry']['month'], (int)$coupon_data['expiry']['day'], (int)$coupon_data['expiry']['year'])); $coupon_data['start'] = $coupon_data['start']." 00:00:00"; $coupon_data['expiry'] = $coupon_data['expiry']." 00:00:00"; $check_values = $wpdb->get_row("SELECT `id`, `coupon_code`, `value`, `is-percentage`, `use-once`, `active`, `start`, `expiry` FROM `".WPSC_TABLE_COUPON_CODES."` WHERE `id` = '$coupon_id'", ARRAY_A); //sort both arrays to make sure that if they contain the same stuff, that they will compare to be the same, may not need to do this, but what the heck // exit('
'.print_r($coupon_data, true).''); ksort($check_values); ksort($coupon_data); if($check_values != $coupon_data) { $insert_array = array(); foreach($coupon_data as $coupon_key => $coupon_value) { if(($coupon_key == "submit_coupon") || ($coupon_key == "delete_coupon")) { continue; } if($coupon_value != $check_values[$coupon_key]) { $insert_array[] = "`$coupon_key` = '$coupon_value'"; } } //if(in_array(mixed needle, array haystack [, bool strict])) //exit("
".print_r($conditions,true).""); if(count($insert_array) > 0) { $wpdb->query("UPDATE `".WPSC_TABLE_COUPON_CODES."` SET ".implode(", ", $insert_array)." WHERE `id` = '$coupon_id' LIMIT 1;"); } unset($insert_array); $rules = $_POST['rules']; foreach ((array)$rules as $key => $rule) { foreach ($rule as $k => $r) { $new_rule[$k][$key] = $r; } } foreach((array)$new_rule as $key => $rule) { if ($rule['value'] == '') { unset($new_rule[$key]); } } /* $sql ="UPDATE `".WPSC_TABLE_COUPON_CODES."` SET `condition`='".serialize($new_rule)."' WHERE `id` = '$coupon_id' LIMIT 1"; $wpdb->query($sql); */ $conditions = $wpdb->get_var("SELECT `condition` FROM `".WPSC_TABLE_COUPON_CODES."` WHERE `id` = '".(int)$_POST['coupon_id']."' LIMIT 1"); $conditions=unserialize($conditions); $new_cond=array(); if($_POST['rules']['value'][0] != ''){ $new_cond['property']=$_POST['rules']['property'][0]; $new_cond['logic']=$_POST['rules']['logic'][0]; $new_cond['value']=$_POST['rules']['value'][0]; $conditions []= $new_cond; } $sql ="UPDATE `".WPSC_TABLE_COUPON_CODES."` SET `condition`='".serialize($conditions)."' WHERE `id` = '".(int)$_POST['coupon_id']."' LIMIT 1"; $wpdb->query($sql); } if($coupon_data['delete_coupon'] != '') { $wpdb->query("DELETE FROM `".WPSC_TABLE_COUPON_CODES."` WHERE `id` = '$coupon_id' LIMIT 1;"); } } } if(isset($_POST['delete_condition'])){ $conditions = $wpdb->get_var("SELECT `condition` FROM `".WPSC_TABLE_COUPON_CODES."` WHERE `id` = '".(int)$_POST['coupon_id']."' LIMIT 1"); $conditions=unserialize($conditions); unset($conditions[(int)$_POST['delete_condition']]); //$conditions = array_values($conditions); // exit('
'.print_r($_POST, true).'
'.print_r($conditions, true).''.$sql); $sql ="UPDATE `".WPSC_TABLE_COUPON_CODES."` SET `condition`='".serialize($conditions)."' WHERE `id` = '".(int)$_POST['coupon_id']."' LIMIT 1"; $wpdb->query($sql); } if(isset($_POST['submit_condition'])){ $conditions = $wpdb->get_var("SELECT `condition` FROM `".WPSC_TABLE_COUPON_CODES."` WHERE `id` = '".(int)$_POST['coupon_id']."' LIMIT 1"); $conditions=unserialize($conditions); $new_cond=array(); $new_cond['property']=$_POST['rules']['property'][0]; $new_cond['logic']=$_POST['rules']['logic'][0]; $new_cond['value']=$_POST['rules']['value'][0]; $conditions []= $new_cond; $sql ="UPDATE `".WPSC_TABLE_COUPON_CODES."` SET `condition`='".serialize($conditions)."' WHERE `id` = '".(int)$_POST['coupon_id']."' LIMIT 1"; $wpdb->query($sql); } if($_POST['change-settings'] == 'true') { if($_POST['wpsc_also_bought'] == 1) { update_option('wpsc_also_bought', 1); } else { update_option('wpsc_also_bought', 0); } if($_POST['display_find_us'] == 'on') { update_option('display_find_us', 1); } else { update_option('display_find_us', 0); } if($_POST['wpsc_share_this'] == 1) { update_option('wpsc_share_this', 1); } else { update_option('wpsc_share_this', 0); } } } /**/ ?>
| ||||||
\n\r"; echo __('Coupon Code', 'wpsc'); echo " | \n\r"; echo "\n\r"; echo __('Discount', 'wpsc'); echo " | \n\r"; echo "\n\r"; echo __('Start', 'wpsc'); echo " | \n\r"; echo "\n\r"; echo __('Expiry', 'wpsc'); echo " | \n\r"; echo "\n\r"; echo __('Active', 'wpsc'); echo " | \n\r"; echo "\n\r"; echo __('Apply On All Products', 'wpsc'); echo " | \n\r"; echo "\n\r"; echo __('Edit', 'wpsc'); echo " | \n\r"; $i=0; $coupon_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_COUPON_CODES."` ",ARRAY_A); //exit('Coupon Data
---|---|---|---|---|---|---|
\n\r"; echo $coupon['coupon_code']; echo " | \n\r"; echo "\n\r"; if($coupon['is-percentage'] == 1){ echo $coupon['value']."%"; } else { echo nzshpcrt_currency_display($coupon['value'], 1); } echo " | \n\r"; echo "\n\r"; echo date("d/m/Y",strtotime($coupon['start'])); echo " | \n\r"; echo "\n\r"; echo date("d/m/Y",strtotime($coupon['expiry'])); echo " | \n\r"; echo "\n\r"; switch($coupon['active']) { case 1: echo ""; break; case 0: default: echo ""; break; } echo " | \n\r"; echo "\n\r"; switch($coupon['every_product']) { case 1: echo ""; break; case 0: default: echo ""; break; } echo " | \n\r"; echo "\n\r"; echo "".__('Edit', 'wpsc').""; echo " | \n\r"; echo "
\n\r";
// $status_style = "style='display: block;'";
echo " \n\r";
coupon_edit_form($coupon);
echo " \n\r";
echo " | \n\r";
echo "
Note: Due to a current limitation of PayPal, if your user makes a purchase and uses a coupon, we can not send a list of items through to paypal for processing. Rather, we must send the total amount of the purchase, so that within PayPal the user who purchases a product will see your shop name and the total amount of their purchase.', 'wpsc');?>
Note: Not only can people use this RSS to keep update with your product list but you can also use this link to promote your products in your facebook profile. Just add the getshopped! facebook application to your facebook profile and follow the instructions.', 'wpsc');?> |
|
RSS Feed Address: |
To import your products into Google Merchant Centre so that they appear within Google Product Search results, sign up for a Google Merchant Centre account and add a scheduled data feed with the following URL: