ID, 'editproduct'); $variations_processor = new nzshpcrt_variations; $wpsc_product_defaults =array ( 'id' => '0', 'name' => '', 'description' => '', 'additional_description' => '', 'price' => '0.00', 'weight' => '0', 'weight_unit' => 'pound', 'pnp' => '0.00', 'international_pnp' => '0.00', 'file' => '0', 'image' => '', 'category' => '0', 'brand' => '0', 'quantity_limited' => '0', 'quantity' => '0', 'special' => '0', 'special_price' => '', 'display_frontpage' => '0', 'notax' => '0', 'publish' => '1', 'active' => '1', 'donation' => '0', 'no_shipping' => '0', 'thumbnail_image' => '', 'thumbnail_state' => '1', 'meta' => array ( 'external_link' => NULL, 'merchant_notes' => NULL, 'sku' => NULL, 'engrave' => '0', 'can_have_uploaded_image' => '0', 'table_rate_price' => array ( 'quantity' => array ( 0 => '', ), 'table_price' => array ( 0 => '', ), ), ), ); function wpsc_display_product_form ($product_id = 0) { global $wpdb, $wpsc_product_defaults; $product_id = absint($product_id); //$variations_processor = new nzshpcrt_variations; if($product_id > 0) { $product_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id`='{$product_id}' LIMIT 1",ARRAY_A); $product_data['meta']['dimensions'] = get_product_meta($product_id, 'dimensions',true); $product_data['meta']['external_link'] = get_product_meta($product_id,'external_link',true); $product_data['meta']['merchant_notes'] = get_product_meta($product_id,'merchant_notes',true); $product_data['meta']['sku'] = get_product_meta($product_id,'sku',true); $product_data['meta']['engrave'] = get_product_meta($product_id,'engraved',true); $product_data['meta']['can_have_uploaded_image'] = get_product_meta($product_id,'can_have_uploaded_image',true); $product_data['meta']['table_rate_price'] = get_product_meta($product_id,'table_rate_price',true); $sql ="SELECT `meta_key`, `meta_value` FROM ".WPSC_TABLE_PRODUCTMETA." WHERE `meta_key` LIKE 'currency%' AND `product_id`=".$product_id; $product_data['newCurr']= $wpdb->get_results($sql, ARRAY_A); //echo "
".print_r($product_data,true)."
"; if(function_exists('wp_insert_term')) { $term_relationships = $wpdb->get_results("SELECT * FROM `{$wpdb->term_relationships}` WHERE object_id = '{$product_id}'", ARRAY_A); foreach ((array)$term_relationships as $term_relationship) { $tt_ids[] = $term_relationship['term_taxonomy_id']; } foreach ((array)$tt_ids as $tt_id) { $term_ids[] = $wpdb->get_var("SELECT `term_id` FROM `{$wpdb->term_taxonomy}` WHERE `term_taxonomy_id` = '{$tt_id}' AND `taxonomy` = 'product_tag' LIMIT 1"); } foreach ((array)$term_ids as $term_id ) { if ($term_id != NULL){ $tags[] = $wpdb->get_var("SELECT `name` FROM `{$wpdb->terms}` WHERE `term_id`='{$term_id}' LIMIT 1"); } } if ($tags != NULL){ $imtags = implode(',', $tags); } } //exit('got called
'.print_r($imtags,true).'
'); $check_variation_value_count = $wpdb->get_var("SELECT COUNT(*) as `count` FROM `".WPSC_TABLE_VARIATION_VALUES_ASSOC."` WHERE `product_id` = '{$product_id}'"); } else { if(isset($_SESSION['wpsc_failed_product_post_data']) && (count($_SESSION['wpsc_failed_product_post_data']) > 0 )) { $product_data = array_merge($wpsc_product_defaults, $_SESSION['wpsc_failed_product_post_data']); $_SESSION['wpsc_failed_product_post_data'] = null; } else { $product_data = $wpsc_product_defaults; } } $product_data = apply_filters('wpsc_display_product_form_get', $product_data); $current_user = wp_get_current_user(); // we put the closed postboxes array into the product data to propagate it to each form without having it global. $product_data['closed_postboxes'] = (array)get_usermeta( $current_user->ID, 'closedpostboxes_store_page_wpsc-edit-products'); $product_data['hidden_postboxes'] = (array)get_usermeta( $current_user->ID, 'metaboxhidden_store_page_wpsc-edit-products'); if(count($product_data) > 0) { wpsc_product_basic_details_form($product_data); } } function wpsc_product_basic_details_form(&$product_data) { global $wpdb,$nzshpcrt_imagesize_info; /*

*/ ?>

0) { echo __('Edit Product', 'wpsc')." (".__('Add Product', 'wpsc').")"; } else { echo __('Add Product', 'wpsc'); } ?>

0) : $i = 0; foreach($product_data['newCurr'] as $newCurr){ $i++; $isocode = str_replace("currency[", "", $newCurr['meta_key']); $isocode = str_replace("]", "", $isocode); // exit('ere
'.print_r($isocode, true).'
'); ?>
' />

Shortcodes

:
[wpsc_products product_id='']
:
[buy_now_button=]
:
[add_to_cart=]

Template Tags

:
<?php echo wpsc_display_products('product_id='); ?>
:
<?php echo wpsc_buy_now_button(); ?>
:
<?php echo wpsc_add_to_cart_button(); ?>
:
<?php echo wpsc_product_sku(); ?>
0 ) { ?>

View product

:
' />
:
' />
' id='add_special'>
+

:

Price :
' />
:
".print_r($order,true).""; if (($order == '') || (count($order ) < 6)){ $order = $default_order; } $check_missing_items = array_diff($default_order, $order); if(count($check_missing_items) > 0) { $order = array_merge($check_missing_items, $order); } update_option('wpsc_product_page_order', $order); foreach((array)$order as $key => $box_function_name) { if(function_exists($box_function_name)) { echo call_user_func(apply_filters('wpsc_product_page_order_form_name', $box_function_name),$product_data); } } ?>
' /> 0) { _e('Update Product', 'wpsc'); } else { _e('Add New Product', 'wpsc'); } ?>' />  ' href='' onclick="if ( confirm(' ') ) { return true;}return false;"> "; if (IS_WP27) { $output .= "

"; } else { $output .= "

+"; } $output .= __('Categories and Tags', 'wpsc'); if ($product_data != '') { if(function_exists('wp_insert_term')) { $term_relationships = $wpdb->get_results("SELECT * FROM `{$wpdb->term_relationships}` WHERE object_id = '{$product_data['id']}'", ARRAY_A); //exit('HERE>
'.print_r($term_relationships,true).'
'); foreach ((array)$term_relationships as $term_relationship) { $tt_ids[] = $term_relationship['term_taxonomy_id']; } foreach ((array)$tt_ids as $tt_id) { $term_ids[] = $wpdb->get_var("SELECT `term_id` FROM `{$wpdb->term_taxonomy}` WHERE `term_taxonomy_id` = '{$tt_id}' AND `taxonomy` = 'product_tag' LIMIT 1"); } foreach ((array)$term_ids as $term_id ) { if ($term_id != NULL){ $tags[] = $wpdb->get_var("SELECT `name` FROM `{$wpdb->terms}` WHERE `term_id`='{$term_id}' LIMIT 1"); } } $imtags = ''; if ($tags != NULL){ $imtags = implode(',', $tags); } //exit('HERE
'.print_r($imtags,true).'
'); } } $output .= "

"; $output .= " "; // // // // //
".__("Separate tags with commas")."
// //

".$imtags."

// $output .= "
".__('Categories', 'wpsc')."
"; $search_sql = apply_filters('wpsc_product_category_and_tag_forms_group_search_sql', ''); $categorisation_groups = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_CATEGORISATION_GROUPS."` WHERE `active` IN ('1')".$search_sql, ARRAY_A); //exit('
'.print_r($categorisation_groups, true).'
'); foreach((array)$categorisation_groups as $categorisation_group){ $category_count = $wpdb->get_var("SELECT COUNT(*) FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `group_id` IN ('{$categorisation_group['id']}')"); if($category_count > 0) { $output .= "

"; $category_group_name = str_replace("[categorisation]", $categorisation_group['name'], __('Select "[categorisation]"', 'wpsc')); $output .= "".$category_group_name.":
"; $output .= "

"; if ($product_data == '') $output .= wpsc_category_list($categorisation_group['id'], false, 'add_', null, 0, 'name' ); else $output .= wpsc_category_list($categorisation_group['id'], $product_data['id'], 'edit_', null, 0, 'name' ); } } $output .= "
".__('Product Tags', 'wpsc')."

".__('Separate tags with commas')."

"; $output = apply_filters('wpsc_product_category_and_tag_forms_output', $output); return $output; } function wpsc_product_price_and_stock_forms($product_data=''){ global $closed_postboxes, $wpdb, $variations_processor; $table_rate_price = get_product_meta($product_data['id'], 'table_rate_price'); $custom_tax = get_product_meta($product_data['id'], 'custom_tax'); if ($product_data == 'empty') { $display = "style='visibility:hidden;'"; } echo "
"; echo "

"; echo __('Price and Stock Control', 'wpsc'); echo "

"; echo " "; echo " "; ?> "; echo "
 
 
0) ? 'checked=\'checked\'' : ''); ?> />
;' id='table_rate'> + Add level
0 ) { foreach((array)$table_rate_price['quantity'] as $key => $qty) { if($qty != '') { ?>
and above
and above
0) ? 'checked=\'checked\'' : ''); ?> />
;' id='custom_tax'>
"; //onclick='hideelement(\"add_stock\")' echo " "; if ($product_data['id'] > 0){ $variations_output = $variations_processor->variations_grid_view($product_data['id']); if(wpsc_product_has_variations($product_data['id'])) { switch($product_data['quantity_limited']) { case 1: echo "
\n\r"; break; default: echo " \n\r"; } else { switch($product_data['quantity_limited']) { case 1: echo "
\n\r"; break; default: echo " \n\r"; } } else { echo " "; } echo "
"; //return $output; } function wpsc_product_variation_forms($product_data=''){ global $closed_postboxes, $variations_processor; $siteurl = get_option('siteurl'); $output=''; if ($product_data == 'empty') { $display = "style='display:none;'"; } ?>
' >


0) { ?>
list_variations($product_data['id']); ?>
variations_grid_view($product_data['id']); ?>
list_variations($product_data['id']); ?>
"; if (IS_WP27) { $output .= "

"; } else { $output .= "

+"; } $output .= __('Shipping Details', 'wpsc'); $output .= "

".__('Weight', 'wpsc')."
".__('Height', 'wpsc')."
".__('Width', 'wpsc')."
".__('Length', 'wpsc')."
".__('Flat Rate Settings', 'wpsc')."
".__('Local Shipping Fee', 'wpsc')."
".__('International Shipping Fee', 'wpsc')."

 
"; return $output; } function wpsc_product_advanced_forms($product_data='') { global $closed_postboxes,$wpdb; //exit('
'.print_r($product_data, true).'
'); $merchant_note = $product_data['meta']['merchant_notes']; $engraved_text = $product_data['meta']['engrave']; $can_have_uploaded_image = $product_data['meta']['can_have_uploaded_image']; $external_link = $product_data['meta']['external_link']; $enable_comments = $product_data['meta']['enable_comments']; $output =''; $custom_fields = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCTMETA."` WHERE `product_id` IN('{$product_data['id']}') AND `custom` IN('1') ",ARRAY_A); if ($product_data == 'empty') { $display = "style='display:none;'"; } $output .= "
"; $output .= "

"; $output .= __('Advanced Options', 'wpsc'); $output .= "

"; $output .= " "; $output .= ""; /* Insert Publish /No Publish Option on Product Edit (1bigidea) */ $output .= ' '; /* End Publish /No Publish Fields */ $output .=" "; if(get_option('payment_gateway') == 'google') { $output .= ""; } ob_start(); do_action('wpsc_add_advanced_options', $product_data['id']); $output .= ob_get_contents(); ob_end_clean(); $output .= " "; if (get_option('wpsc_enable_comments') == 1) { $output .= " "; } $output .= "
".__('Custom Meta', 'wpsc').":
+ ".__('Add Custom Meta', 'wpsc')."

"; foreach((array)$custom_fields as $custom_field) { $i = $custom_field['id']; $custom_meta_value = stripslashes($custom_field['meta_value']); $output .= "
".__('Name', 'wpsc')." ".__('Value', 'wpsc')." ".__('Delete')."
"; } $output .= "
".__('Name', 'wpsc').":

".__('Description', 'wpsc').":


". __('Merchant Notes', 'wpsc') .":
".__('These notes are only available here.', 'wpsc')."

'.__("Publish").':

". __('Personalisation Options', 'wpsc') .":




".__('Off Site Product Link', 'wpsc').":
".__('If this product is for sale on another website enter the link here. For instance if your product is an MP3 file for sale on itunes you could put the link here. This option over rides the buy now and add to cart links and takes you to the site linked here.', 'wpsc')."

:

".__('Enable IntenseDebate Comments', 'wpsc').":

".__('Allow users to comment on this product.', 'wpsc')."
"; return $output; } function wpsc_product_image_forms($product_data='') { global $closed_postboxes; if ($product_data == 'empty') { $display = "style='display:none;'"; } //echo "
".print_r($product_data,true)."
"; //As in WordPress, If Mac and mod_security, no Flash $flash = true; if ( (false !== strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'mac')) && apache_mod_loaded('mod_security') ) { $flash = false; } $flash_action_url = admin_url('async-upload.php'); $flash = apply_filters('flash_uploader', $flash); ?>
' >


Browser uploader instead.', 'wpsc'); ?>

install the premium upgrade'); ?>

Flash uploader instead.', 'wpsc'); ?>


>

"; $output .= "

".__('Product Download', 'wpsc')."

"; $output .= "
"; $output .= "

".__('Upload File', 'wpsc').":

"; $output .= "
".__('Max Upload Size', 'wpsc')." : ".$upload_max."

"; $output .= wpsc_select_product_file($product_data['id'])."
"; if($product_data['file'] > 0) { $output .= __('Preview File', 'wpsc').": "; $output .= "".__('Click to download', 'wpsc').""; $file_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PRODUCT_FILES."` WHERE `id`='".$product_data['file']."' LIMIT 1",ARRAY_A); if(($file_data != null) && (function_exists('listen_button'))) { $output .= "".listen_button($file_data['idhash'], $file_data['id'])."

"; } } if(function_exists("make_mp3_preview") || function_exists("wpsc_media_player")) { $output .="

".__("Select an MP3 file to upload as a preview")."

"; $output .= "
"; $output .= "
"; } $output .="
"; return $output; } function wpsc_product_label_forms() { global $closed_postboxes; ?>
'> "; } else { echo "

+"; } ?>

:
:
:
:
:
:
:
0) { $main_image = $wpdb->get_row("SELECT `images`.* FROM `".WPSC_TABLE_PRODUCT_IMAGES."` AS `images` JOIN `".WPSC_TABLE_PRODUCT_LIST."` AS `product` ON `product`.`image` = `images`.`id` WHERE `product`.`id` = '{$product_data['id']}' LIMIT 1", ARRAY_A); } $timestamp = time(); ?> 0) { $main_image = $wpdb->get_row("SELECT `images`.*, `product`.`thumbnail_state` FROM `".WPSC_TABLE_PRODUCT_IMAGES."` AS `images` JOIN `".WPSC_TABLE_PRODUCT_LIST."` AS `product` ON `product`.`image` = `images`.`id` WHERE `product`.`id` = '{$product_id}' LIMIT 1", ARRAY_A); $thumbnail_state = $main_image['thumbnail_state']; } else { $thumbnail_state = 1; } $sendback = wp_get_referer(); $presentation_link = add_query_arg('page','wpsc-settings', $sendback); $presentation_link = add_query_arg('tab','presentation#thumb_settings', $presentation_link); $thumbnail_image_height = get_product_meta($product_id, 'thumbnail_height'); $thumbnail_image_width = get_product_meta($product_id, 'thumbnail_width'); // echo $thumbnail_image_height; // echo "|"; // echo $thumbnail_image_width; ob_start(); ?>
Edit get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `group_id` IN ('$group_id') AND `active`='1' AND `category_parent` = '$category_id' ORDER BY `$orderby` ASC",ARRAY_A); } else { $values = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `group_id` IN ('$group_id') AND `active`='1' AND `category_parent` = '0' ORDER BY `$orderby` ASC",ARRAY_A); } if($category_id < 1) { $output .= "