# --- BEGIN PLUGIN HELP ---
For display information visit:
http://homeplatewp.com/TextCommerce/article/67/tc_product_display-001
# --- END PLUGIN HELP ---
';
echo '';
$step = "update";
//CSS FOR SETTINGS EDIT
//==================================
echo n.'';
//JS
//==================================
doJS();
echo startTable('edit').
'
'.n;
//if ($view == 'text')
//{
//-- markup help --------------
echo '| '.
n.' | ';
echo ''.n;
//General Settings
//========================================
echo "";
extract($general_settings);
echo n.n.' ';
//Shipping Zones
//========================================
echo "';
echo n." Your Regions";
echo ' ";
echo n.' ';
//Shipping Rates
//========================================
echo "".
n." Shipping Rates";
$zones = safe_rows("*", "shipping_zones", "1");
foreach($zones as $zone){
extract($zone);
echo ' ';
$sql = "select *, shipping_rates.id as shipping_rate_id from shipping_rates
JOIN zones_rates
ON zones_rates.shipping_rate_id = shipping_rates.id
JOIN shipping_zones
ON shipping_zones.id = zones_rates.shipping_zone_id
WHERE zones_rates.shipping_zone_id = $id";
$rates = safe_query($sql);
echo ' ';
if(mysql_num_rows($rates) > 0){
echo n.'| Label | Amount | Weight Range | ';
}
$background = "#FFFFFF";
while($rate = mysql_fetch_assoc($rates)){
echo '| ';
echo n.n.'';
echo " | ";
if($background == "#F6F6F6"){
$background = "#FFFFFF";
}else{
$background = "#F6F6F6";
}
}
echo ' ';
echo br.n.n.' ';
}
echo n.' ';
//Notices Management
//========================================
echo "".
n." Notices";
echo n.n.' ';
if(isset($show_panel)){
if($show_panel == "zones"){
echo '';
}else if($show_panel == "rates"){
echo '';
}else if($show_panel == "notices"){
echo '';
}
}
echo ' | ';
echo '
';
} //--- end settings
function settings_update($event, $step){
global $txp_user, $vars, $txpcfg, $prefs;
extract(doSlash($_REQUEST));
if($settings_update == "general"){
if(!isset($inventory_management_on)){
$inventory_management_on = 0;
}
if(!isset($send_low_inventory_email_notification)){
$send_low_inventory_email_notification = 0;
}
$storeSettingExist = safe_count("store_settings", "1"); //do we even have any store settings?
if($storeSettingExist > 0){
$return = safe_update("store_settings",
"inventory_management_on = $inventory_management_on,
hide_inventory_when_depleted = $hide_inventory_when_depleted,
depleted_inventory_message = '$depleted_inventory_message',
send_low_inventory_email_notification = $send_low_inventory_email_notification,
store_address = '$store_address',
store_city = '$store_city',
store_state = '$store_state',
store_zip = '$store_zip',
store_country = '$store_country',
owner_email = '$owner_email',
unit_system = '$unit_system',
store_currency = '$store_currency'", "1");
}else{
$return = safe_insert("store_settings",
"inventory_management_on = $inventory_management_on,
hide_inventory_when_depleted = $hide_inventory_when_depleted,
depleted_inventory_message = '$depleted_inventory_message',
send_low_inventory_email_notification = $send_low_inventory_email_notification,
store_address = '$store_address',
store_city = '$store_city',
store_state = '$store_state',
store_zip = '$store_zip',
store_country = '$store_country',
owner_email = '$owner_email',
unit_system = '$unit_system',
store_currency = '$store_currency'");
}
if(!$return){
echo mysql_error();
}else{
settings_edit($event, $step, $message='General settings updated');
}
}else if($settings_update == "add_zone"){
$country = safe_row("name", "countries", "id=$country_id");
$country = $country['name'];
if(!isset($shipping_rate_id)){
$shipping_rate_id = 'NULL';
}
$return = safe_insert("shipping_zones",
"name = '$country',
country_id = $country_id,
tax_rate = $tax_rate,
shipping_rate_id=$shipping_rate_id");
if(!$return){
echo mysql_error();
}else{
settings_edit($event, $step, $message='Shipping region added', "zones");
}
}else if($settings_update == "delete_zone"){
$return = safe_delete("shipping_zones", "id=$id");
if(!$return){
echo mysql_error();
}else{
settings_edit($event, $step, $message='Shipping region deleted', "zones");
}
}else if($settings_update == "update_zone"){
$return = safe_update("shipping_zones",
"tax_rate = $tax_rate",
"id=$id");
if(!$return){
echo mysql_error();
}else{
settings_edit($event, $step, $message='Shipping region updated', "zones");
}
}else if($settings_update == "update_zone"){
$return = safe_update("shipping_zones",
"tax_rate = $tax_rate",
"id=$id");
if(!$return){
echo mysql_error();
}else{
settings_edit($event, $step, $message='Shipping region updated', "zones");
}
}else if($settings_update == "update_rate"){
$return = safe_update("shipping_rates",
"title = '$title',
rate = $rate,
start_weight = $start_weight,
end_weight = $end_weight",
"id=$shipping_rate_id");
if(!$return){
echo mysql_error();
}else{
settings_edit($event, $step, $message='Shipping rate updated', "rates");
}
}else if($settings_update == "add_rate"){
$rate_id = safe_insert("shipping_rates",
"title = '$title',
rate = $rate,
start_weight = $start_weight,
end_weight = $end_weight");
if(!$rate_id){
echo mysql_error();
die();
}
$return = safe_insert("zones_rates",
"shipping_rate_id = $rate_id,
shipping_zone_id = $id");
if(!$return){
echo mysql_error();
}else{
settings_edit($event, $step, $message='Shipping rate added', "rates");
}
}else if($settings_update == "delete_rate"){
$result = safe_delete("shipping_rates", "id=$shipping_rate_id");
if(!$result){
echo mysql_error();
die();
}
$result = safe_delete("zones_rates",
"shipping_rate_id = $shipping_rate_id AND
shipping_zone_id = $id");
if(!$result){
echo mysql_error();
}else{
settings_edit($event, $step, $message='Shipping rate deleted', "rates");
}
}else if($settings_update == "notices"){
$result = $return = safe_update("store_settings",
"order_confirmation_form = '$order_confirmation_form',
new_order_notification_form = '$new_order_notification_form'",
"1");
if(!$result){
echo mysql_error();
}else{
settings_edit($event, $step, $message='Notices updated', "notices");
}
}
}
?>