From eb244fad2b475b76f3ed2adaf9e5977e3daeda57 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 10 Feb 2021 18:14:07 +0000 Subject: [PATCH 01/17] PHP 8 Compatibility PHP changes to help with PHP 8 compatibility. --- wpsc-components/theme-engine-v1/helpers/product.php | 2 +- .../theme-engine-v1/widgets/latest_product_widget.php | 2 +- wpsc-components/theme-engine-v1/widgets/specials_widget.php | 2 +- wpsc-core/wpsc-deprecated.php | 2 +- wpsc-includes/cart-template-api.php | 2 +- wpsc-includes/meta.functions.php | 6 +++--- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/wpsc-components/theme-engine-v1/helpers/product.php b/wpsc-components/theme-engine-v1/helpers/product.php index b8bad28122..3d65ea9792 100644 --- a/wpsc-components/theme-engine-v1/helpers/product.php +++ b/wpsc-components/theme-engine-v1/helpers/product.php @@ -158,7 +158,7 @@ function wpsc_list_categories($callback_function, $parameters = null, $category_ * Gets the Function Parent Image link and checks whether Image should be displayed or not * */ -function wpsc_parent_category_image($show_thumbnails , $category_image , $width, $height, $grid=false, $show_name){ +function wpsc_parent_category_image($show_thumbnails , $category_image , $width, $height, $show_name, $grid=false ){ if(!$show_thumbnails) return; diff --git a/wpsc-components/theme-engine-v1/widgets/latest_product_widget.php b/wpsc-components/theme-engine-v1/widgets/latest_product_widget.php index 87b739f5d5..af241f1158 100755 --- a/wpsc-components/theme-engine-v1/widgets/latest_product_widget.php +++ b/wpsc-components/theme-engine-v1/widgets/latest_product_widget.php @@ -115,7 +115,7 @@ function form( $instance ) { return register_widget( 'WP_Widget_Latest_Products' ); } ); -function wpsc_latest_product( $args = null, $instance ) { +function wpsc_latest_product( $args, $instance ) { global $wpdb; $args = wp_parse_args( (array)$args, array( 'number' => 5 ) ); $options = get_option( 'wpsc-widget_latest_products' ); diff --git a/wpsc-components/theme-engine-v1/widgets/specials_widget.php b/wpsc-components/theme-engine-v1/widgets/specials_widget.php index 7e17cd7bed..be6e831b06 100755 --- a/wpsc-components/theme-engine-v1/widgets/specials_widget.php +++ b/wpsc-components/theme-engine-v1/widgets/specials_widget.php @@ -170,7 +170,7 @@ function _wpsc_filter_special_widget_join( $join ) { * 5. Function now expect a single paramter with an array of options (used to be a string which prepended the output). */ -function wpsc_specials( $args = null, $instance ) { +function wpsc_specials( $args , $instance ) { global $wpdb; diff --git a/wpsc-core/wpsc-deprecated.php b/wpsc-core/wpsc-deprecated.php index f64cf715c6..dae8c5493e 100644 --- a/wpsc-core/wpsc-deprecated.php +++ b/wpsc-core/wpsc-deprecated.php @@ -89,7 +89,7 @@ function nzshpcrt_donations($args){ * 4. The product list is enclosed in a
with a 'wpec-latest-products' class. * 5. Function now expects two arrays as per the standard Widget API. */ -function nzshpcrt_latest_product( $args = null, $instance ) { +function nzshpcrt_latest_product( $args, $instance ) { _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_latest_product'); echo wpsc_latest_product( $args, $instance ); } diff --git a/wpsc-includes/cart-template-api.php b/wpsc-includes/cart-template-api.php index b7e7e656de..389445a6f9 100644 --- a/wpsc-includes/cart-template-api.php +++ b/wpsc-includes/cart-template-api.php @@ -469,7 +469,7 @@ function _wpsc_validate_cart_product_quantity( $product_id, $parameters, $cart ) * @return array of shipping options */ function wpsc_selfURL() { - $s = empty( $_SERVER ['HTTPS'] ) ? '' : ( $_SERVER ['HTTPS'] == 'on' ) ? 's' : ''; + $s = empty( $_SERVER ['HTTPS'] ) ? '' : (( $_SERVER ['HTTPS'] == 'on' ) ? 's' : ''); $protocol = wpsc_strleft( strtolower( $_SERVER ['SERVER_PROTOCOL'] ), '/' ) . $s; $port = ( $_SERVER ['SERVER_PORT'] == '80' ) ? '' : ( ':' . $_SERVER ['SERVER_PORT'] ); return $protocol . '://' . $_SERVER ['SERVER_NAME'] . $port . $_SERVER ['REQUEST_URI']; diff --git a/wpsc-includes/meta.functions.php b/wpsc-includes/meta.functions.php index deb863e23a..6b2ff7467a 100755 --- a/wpsc-includes/meta.functions.php +++ b/wpsc-includes/meta.functions.php @@ -21,7 +21,7 @@ function wpsc_sanitize_meta_key( $key ) { * @param string $object_type Object type. * @return mixed Meta value. */ -function wpsc_get_meta( $object_id = 0, $meta_key, $object_type ) { +function wpsc_get_meta( $object_id , $meta_key, $object_type ) { global $wpdb; @@ -60,7 +60,7 @@ function wpsc_get_meta( $object_id = 0, $meta_key, $object_type ) { * @param boolean $global ? * @return boolean */ -function wpsc_update_meta( $object_id = 0, $meta_key, $meta_value, $object_type, $global = false ) { +function wpsc_update_meta( $object_id, $meta_key, $meta_value, $object_type, $global = false ) { global $wpdb; @@ -105,7 +105,7 @@ function wpsc_update_meta( $object_id = 0, $meta_key, $meta_value, $object_type, * @param boolean $global ? * @return boolean */ -function wpsc_delete_meta( $object_id = 0, $meta_key, $meta_value, $object_type, $global = false ) { +function wpsc_delete_meta( $object_id, $meta_key, $meta_value, $object_type, $global = false ) { global $wpdb; From f0107e7c95b848fe9a176de7d978e02c8c66817a Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 11 Feb 2021 10:01:22 +0000 Subject: [PATCH 02/17] PHP 8 Changes Tidy up comma's --- wpsc-components/theme-engine-v1/widgets/specials_widget.php | 2 +- wpsc-includes/meta.functions.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wpsc-components/theme-engine-v1/widgets/specials_widget.php b/wpsc-components/theme-engine-v1/widgets/specials_widget.php index be6e831b06..23f523a8b5 100755 --- a/wpsc-components/theme-engine-v1/widgets/specials_widget.php +++ b/wpsc-components/theme-engine-v1/widgets/specials_widget.php @@ -170,7 +170,7 @@ function _wpsc_filter_special_widget_join( $join ) { * 5. Function now expect a single paramter with an array of options (used to be a string which prepended the output). */ -function wpsc_specials( $args , $instance ) { +function wpsc_specials( $args, $instance ) { global $wpdb; diff --git a/wpsc-includes/meta.functions.php b/wpsc-includes/meta.functions.php index 6b2ff7467a..7704d80527 100755 --- a/wpsc-includes/meta.functions.php +++ b/wpsc-includes/meta.functions.php @@ -21,7 +21,7 @@ function wpsc_sanitize_meta_key( $key ) { * @param string $object_type Object type. * @return mixed Meta value. */ -function wpsc_get_meta( $object_id , $meta_key, $object_type ) { +function wpsc_get_meta( $object_id, $meta_key, $object_type ) { global $wpdb; From 6cc48317dc7bece05a290fd8a9e7c3cc9edda1f4 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 18 Feb 2021 11:23:39 +0000 Subject: [PATCH 03/17] Set PayPal payments to authorisations Added the option to be able to choose if you would like PayPal payments to come through as either authorisations, or completed payments, from within the store settings page on the PayPal Payments Standard 2.0 gateway. --- .../theme-engine-v1/helpers/product.php | 2 +- .../widgets/latest_product_widget.php | 2 +- .../widgets/specials_widget.php | 4 ++ wpsc-core/wpsc-deprecated.php | 2 +- wpsc-includes/cart-template-api.php | 2 +- wpsc-includes/meta.functions.php | 8 ++- wpsc-merchants/paypal-standard.merchant.php | 59 ++++++++++++++++--- 7 files changed, 64 insertions(+), 15 deletions(-) diff --git a/wpsc-components/theme-engine-v1/helpers/product.php b/wpsc-components/theme-engine-v1/helpers/product.php index 3d65ea9792..b8bad28122 100644 --- a/wpsc-components/theme-engine-v1/helpers/product.php +++ b/wpsc-components/theme-engine-v1/helpers/product.php @@ -158,7 +158,7 @@ function wpsc_list_categories($callback_function, $parameters = null, $category_ * Gets the Function Parent Image link and checks whether Image should be displayed or not * */ -function wpsc_parent_category_image($show_thumbnails , $category_image , $width, $height, $show_name, $grid=false ){ +function wpsc_parent_category_image($show_thumbnails , $category_image , $width, $height, $grid=false, $show_name){ if(!$show_thumbnails) return; diff --git a/wpsc-components/theme-engine-v1/widgets/latest_product_widget.php b/wpsc-components/theme-engine-v1/widgets/latest_product_widget.php index af241f1158..87b739f5d5 100755 --- a/wpsc-components/theme-engine-v1/widgets/latest_product_widget.php +++ b/wpsc-components/theme-engine-v1/widgets/latest_product_widget.php @@ -115,7 +115,7 @@ function form( $instance ) { return register_widget( 'WP_Widget_Latest_Products' ); } ); -function wpsc_latest_product( $args, $instance ) { +function wpsc_latest_product( $args = null, $instance ) { global $wpdb; $args = wp_parse_args( (array)$args, array( 'number' => 5 ) ); $options = get_option( 'wpsc-widget_latest_products' ); diff --git a/wpsc-components/theme-engine-v1/widgets/specials_widget.php b/wpsc-components/theme-engine-v1/widgets/specials_widget.php index 23f523a8b5..4faaa00ffa 100755 --- a/wpsc-components/theme-engine-v1/widgets/specials_widget.php +++ b/wpsc-components/theme-engine-v1/widgets/specials_widget.php @@ -170,7 +170,11 @@ function _wpsc_filter_special_widget_join( $join ) { * 5. Function now expect a single paramter with an array of options (used to be a string which prepended the output). */ +<<<<<<< HEAD function wpsc_specials( $args, $instance ) { +======= +function wpsc_specials( $args = null, $instance ) { +>>>>>>> parent of eb244fad (PHP 8 Compatibility) global $wpdb; diff --git a/wpsc-core/wpsc-deprecated.php b/wpsc-core/wpsc-deprecated.php index dae8c5493e..f64cf715c6 100644 --- a/wpsc-core/wpsc-deprecated.php +++ b/wpsc-core/wpsc-deprecated.php @@ -89,7 +89,7 @@ function nzshpcrt_donations($args){ * 4. The product list is enclosed in a
with a 'wpec-latest-products' class. * 5. Function now expects two arrays as per the standard Widget API. */ -function nzshpcrt_latest_product( $args, $instance ) { +function nzshpcrt_latest_product( $args = null, $instance ) { _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_latest_product'); echo wpsc_latest_product( $args, $instance ); } diff --git a/wpsc-includes/cart-template-api.php b/wpsc-includes/cart-template-api.php index 389445a6f9..b7e7e656de 100644 --- a/wpsc-includes/cart-template-api.php +++ b/wpsc-includes/cart-template-api.php @@ -469,7 +469,7 @@ function _wpsc_validate_cart_product_quantity( $product_id, $parameters, $cart ) * @return array of shipping options */ function wpsc_selfURL() { - $s = empty( $_SERVER ['HTTPS'] ) ? '' : (( $_SERVER ['HTTPS'] == 'on' ) ? 's' : ''); + $s = empty( $_SERVER ['HTTPS'] ) ? '' : ( $_SERVER ['HTTPS'] == 'on' ) ? 's' : ''; $protocol = wpsc_strleft( strtolower( $_SERVER ['SERVER_PROTOCOL'] ), '/' ) . $s; $port = ( $_SERVER ['SERVER_PORT'] == '80' ) ? '' : ( ':' . $_SERVER ['SERVER_PORT'] ); return $protocol . '://' . $_SERVER ['SERVER_NAME'] . $port . $_SERVER ['REQUEST_URI']; diff --git a/wpsc-includes/meta.functions.php b/wpsc-includes/meta.functions.php index 7704d80527..6255c0e254 100755 --- a/wpsc-includes/meta.functions.php +++ b/wpsc-includes/meta.functions.php @@ -21,7 +21,11 @@ function wpsc_sanitize_meta_key( $key ) { * @param string $object_type Object type. * @return mixed Meta value. */ +<<<<<<< HEAD function wpsc_get_meta( $object_id, $meta_key, $object_type ) { +======= +function wpsc_get_meta( $object_id = 0, $meta_key, $object_type ) { +>>>>>>> parent of eb244fad (PHP 8 Compatibility) global $wpdb; @@ -60,7 +64,7 @@ function wpsc_get_meta( $object_id, $meta_key, $object_type ) { * @param boolean $global ? * @return boolean */ -function wpsc_update_meta( $object_id, $meta_key, $meta_value, $object_type, $global = false ) { +function wpsc_update_meta( $object_id = 0, $meta_key, $meta_value, $object_type, $global = false ) { global $wpdb; @@ -105,7 +109,7 @@ function wpsc_update_meta( $object_id, $meta_key, $meta_value, $object_type, $gl * @param boolean $global ? * @return boolean */ -function wpsc_delete_meta( $object_id, $meta_key, $meta_value, $object_type, $global = false ) { +function wpsc_delete_meta( $object_id = 0, $meta_key, $meta_value, $object_type, $global = false ) { global $wpdb; diff --git a/wpsc-merchants/paypal-standard.merchant.php b/wpsc-merchants/paypal-standard.merchant.php index 137aa2ee1c..ed766fb8d4 100755 --- a/wpsc-merchants/paypal-standard.merchant.php +++ b/wpsc-merchants/paypal-standard.merchant.php @@ -125,10 +125,18 @@ function _construct_value_array( $aggregate = false ) { 'currency_code' => $this->get_paypal_currency_code(), 'lc' => $this->cart_data['store_currency'], 'no_note' => '1', - 'charset' => 'utf-8', - ); - - // IPN data + 'charset' => 'utf-8', + + ); + + // Set PayPal payments to come through as authorisations + if (get_option('authorisation_or_completed_payment') == 1) { + $paypal_vars += array( + 'paymentaction' => 'authorization' + ); + } + + // IPN data if (get_option('paypal_ipn') == 1) { $notify_url = $this->cart_data['notification_url']; $notify_url = add_query_arg('gateway', 'wpsc_merchant_paypal_standard', $notify_url); @@ -170,9 +178,10 @@ function _construct_value_array( $aggregate = false ) { // Order settings to be sent to paypal $paypal_vars += array( 'invoice' => $this->cart_data['session_id'] + ); - - if ( $buy_now ) { + + if ( $buy_now ) { $paypal_vars['custom'] = 'buy_now'; } @@ -651,11 +660,15 @@ function submit_paypal_multiple (){ update_option( 'paypal_ship', (int) $_POST['paypal_ship'] ); } + if ( isset( $_POST['authorisation_or_completed_payment'] ) ) { + update_option( 'authorisation_or_completed_payment', (int) $_POST['authorisation_or_completed_payment'] ); + } + if ( ! isset( $_POST['paypal_form'] ) ) { $_POST['paypal_form'] = array(); } - foreach( (array) $_POST['paypal_form'] as $form => $value ) { + foreach( (array) $_POST['paypal_form'] as $form => $value ) { update_option( 'paypal_form_' . $form, sanitize_text_field( $value ) ); } @@ -749,7 +762,22 @@ function form_paypal_multiple() { $address_override2 = "checked='checked'"; break; } + + $authorisation_or_completed_payment = get_option( 'authorisation_or_completed_payment' ); + $authorisation_or_completed_payment1 = ""; + $authorisation_or_completed_payment2 = ""; + switch( $authorisation_or_completed_payment ) { + case 1: + $authorisation_or_completed_payment1 = "checked= 'checked'"; + break; + + case 0: + default: + $authorisation_or_completed_payment2 = "checked='checked'"; + break; + } $output .= " + " . __( "IPN", 'wp-e-commerce' ) . ": @@ -781,8 +809,21 @@ function form_paypal_multiple() { " . __( "This setting affects your PayPal purchase log. If your customers already have a PayPal account, PayPal will try to populate your PayPal Purchase Log with their PayPal address. This setting tries to replace the address in the PayPal purchase log with the address customers enter on your Checkout page.", 'wp-e-commerce' ) . "

- \n"; - + + + + + " . __( 'Payment Authorisations:', 'wp-e-commerce' ) . " + + +   + +

+ " . __( "This setting allows you to choose if you with to have PayPal payments come through as authorisations, or completed payments. Tick yes for payments to come through as authorisations, or no for payments to come through as completed payments. If set to authorisations, you will then be able to capture or void the transaction from within your PayPal account.", 'wp-e-commerce' ) . " +

+ + \n"; + $store_currency_data = WPSC_Countries::get_currency_data( get_option( 'currency_type' ), true ); $current_currency = get_option('paypal_curcode'); if ( ( $current_currency == '' ) && in_array( $store_currency_data['code'], $wpsc_gateways['wpsc_merchant_paypal_standard']['supported_currencies']['currency_list'] ) ) { From 112d08d689a822c3870fe78f9dc80e05f2b605f6 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 18 Feb 2021 12:07:26 +0000 Subject: [PATCH 04/17] Revert "Set PayPal payments to authorisations" This reverts commit 6cc48317dc7bece05a290fd8a9e7c3cc9edda1f4. --- .../theme-engine-v1/helpers/product.php | 2 +- .../widgets/latest_product_widget.php | 2 +- .../widgets/specials_widget.php | 4 -- wpsc-core/wpsc-deprecated.php | 2 +- wpsc-includes/cart-template-api.php | 2 +- wpsc-includes/meta.functions.php | 8 +-- wpsc-merchants/paypal-standard.merchant.php | 59 +++---------------- 7 files changed, 15 insertions(+), 64 deletions(-) diff --git a/wpsc-components/theme-engine-v1/helpers/product.php b/wpsc-components/theme-engine-v1/helpers/product.php index b8bad28122..3d65ea9792 100644 --- a/wpsc-components/theme-engine-v1/helpers/product.php +++ b/wpsc-components/theme-engine-v1/helpers/product.php @@ -158,7 +158,7 @@ function wpsc_list_categories($callback_function, $parameters = null, $category_ * Gets the Function Parent Image link and checks whether Image should be displayed or not * */ -function wpsc_parent_category_image($show_thumbnails , $category_image , $width, $height, $grid=false, $show_name){ +function wpsc_parent_category_image($show_thumbnails , $category_image , $width, $height, $show_name, $grid=false ){ if(!$show_thumbnails) return; diff --git a/wpsc-components/theme-engine-v1/widgets/latest_product_widget.php b/wpsc-components/theme-engine-v1/widgets/latest_product_widget.php index 87b739f5d5..af241f1158 100755 --- a/wpsc-components/theme-engine-v1/widgets/latest_product_widget.php +++ b/wpsc-components/theme-engine-v1/widgets/latest_product_widget.php @@ -115,7 +115,7 @@ function form( $instance ) { return register_widget( 'WP_Widget_Latest_Products' ); } ); -function wpsc_latest_product( $args = null, $instance ) { +function wpsc_latest_product( $args, $instance ) { global $wpdb; $args = wp_parse_args( (array)$args, array( 'number' => 5 ) ); $options = get_option( 'wpsc-widget_latest_products' ); diff --git a/wpsc-components/theme-engine-v1/widgets/specials_widget.php b/wpsc-components/theme-engine-v1/widgets/specials_widget.php index 4faaa00ffa..23f523a8b5 100755 --- a/wpsc-components/theme-engine-v1/widgets/specials_widget.php +++ b/wpsc-components/theme-engine-v1/widgets/specials_widget.php @@ -170,11 +170,7 @@ function _wpsc_filter_special_widget_join( $join ) { * 5. Function now expect a single paramter with an array of options (used to be a string which prepended the output). */ -<<<<<<< HEAD function wpsc_specials( $args, $instance ) { -======= -function wpsc_specials( $args = null, $instance ) { ->>>>>>> parent of eb244fad (PHP 8 Compatibility) global $wpdb; diff --git a/wpsc-core/wpsc-deprecated.php b/wpsc-core/wpsc-deprecated.php index f64cf715c6..dae8c5493e 100644 --- a/wpsc-core/wpsc-deprecated.php +++ b/wpsc-core/wpsc-deprecated.php @@ -89,7 +89,7 @@ function nzshpcrt_donations($args){ * 4. The product list is enclosed in a
with a 'wpec-latest-products' class. * 5. Function now expects two arrays as per the standard Widget API. */ -function nzshpcrt_latest_product( $args = null, $instance ) { +function nzshpcrt_latest_product( $args, $instance ) { _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_latest_product'); echo wpsc_latest_product( $args, $instance ); } diff --git a/wpsc-includes/cart-template-api.php b/wpsc-includes/cart-template-api.php index b7e7e656de..389445a6f9 100644 --- a/wpsc-includes/cart-template-api.php +++ b/wpsc-includes/cart-template-api.php @@ -469,7 +469,7 @@ function _wpsc_validate_cart_product_quantity( $product_id, $parameters, $cart ) * @return array of shipping options */ function wpsc_selfURL() { - $s = empty( $_SERVER ['HTTPS'] ) ? '' : ( $_SERVER ['HTTPS'] == 'on' ) ? 's' : ''; + $s = empty( $_SERVER ['HTTPS'] ) ? '' : (( $_SERVER ['HTTPS'] == 'on' ) ? 's' : ''); $protocol = wpsc_strleft( strtolower( $_SERVER ['SERVER_PROTOCOL'] ), '/' ) . $s; $port = ( $_SERVER ['SERVER_PORT'] == '80' ) ? '' : ( ':' . $_SERVER ['SERVER_PORT'] ); return $protocol . '://' . $_SERVER ['SERVER_NAME'] . $port . $_SERVER ['REQUEST_URI']; diff --git a/wpsc-includes/meta.functions.php b/wpsc-includes/meta.functions.php index 6255c0e254..7704d80527 100755 --- a/wpsc-includes/meta.functions.php +++ b/wpsc-includes/meta.functions.php @@ -21,11 +21,7 @@ function wpsc_sanitize_meta_key( $key ) { * @param string $object_type Object type. * @return mixed Meta value. */ -<<<<<<< HEAD function wpsc_get_meta( $object_id, $meta_key, $object_type ) { -======= -function wpsc_get_meta( $object_id = 0, $meta_key, $object_type ) { ->>>>>>> parent of eb244fad (PHP 8 Compatibility) global $wpdb; @@ -64,7 +60,7 @@ function wpsc_get_meta( $object_id = 0, $meta_key, $object_type ) { * @param boolean $global ? * @return boolean */ -function wpsc_update_meta( $object_id = 0, $meta_key, $meta_value, $object_type, $global = false ) { +function wpsc_update_meta( $object_id, $meta_key, $meta_value, $object_type, $global = false ) { global $wpdb; @@ -109,7 +105,7 @@ function wpsc_update_meta( $object_id = 0, $meta_key, $meta_value, $object_type, * @param boolean $global ? * @return boolean */ -function wpsc_delete_meta( $object_id = 0, $meta_key, $meta_value, $object_type, $global = false ) { +function wpsc_delete_meta( $object_id, $meta_key, $meta_value, $object_type, $global = false ) { global $wpdb; diff --git a/wpsc-merchants/paypal-standard.merchant.php b/wpsc-merchants/paypal-standard.merchant.php index ed766fb8d4..137aa2ee1c 100755 --- a/wpsc-merchants/paypal-standard.merchant.php +++ b/wpsc-merchants/paypal-standard.merchant.php @@ -125,18 +125,10 @@ function _construct_value_array( $aggregate = false ) { 'currency_code' => $this->get_paypal_currency_code(), 'lc' => $this->cart_data['store_currency'], 'no_note' => '1', - 'charset' => 'utf-8', - - ); - - // Set PayPal payments to come through as authorisations - if (get_option('authorisation_or_completed_payment') == 1) { - $paypal_vars += array( - 'paymentaction' => 'authorization' - ); - } - - // IPN data + 'charset' => 'utf-8', + ); + + // IPN data if (get_option('paypal_ipn') == 1) { $notify_url = $this->cart_data['notification_url']; $notify_url = add_query_arg('gateway', 'wpsc_merchant_paypal_standard', $notify_url); @@ -178,10 +170,9 @@ function _construct_value_array( $aggregate = false ) { // Order settings to be sent to paypal $paypal_vars += array( 'invoice' => $this->cart_data['session_id'] - ); - - if ( $buy_now ) { + + if ( $buy_now ) { $paypal_vars['custom'] = 'buy_now'; } @@ -660,15 +651,11 @@ function submit_paypal_multiple (){ update_option( 'paypal_ship', (int) $_POST['paypal_ship'] ); } - if ( isset( $_POST['authorisation_or_completed_payment'] ) ) { - update_option( 'authorisation_or_completed_payment', (int) $_POST['authorisation_or_completed_payment'] ); - } - if ( ! isset( $_POST['paypal_form'] ) ) { $_POST['paypal_form'] = array(); } - foreach( (array) $_POST['paypal_form'] as $form => $value ) { + foreach( (array) $_POST['paypal_form'] as $form => $value ) { update_option( 'paypal_form_' . $form, sanitize_text_field( $value ) ); } @@ -762,22 +749,7 @@ function form_paypal_multiple() { $address_override2 = "checked='checked'"; break; } - - $authorisation_or_completed_payment = get_option( 'authorisation_or_completed_payment' ); - $authorisation_or_completed_payment1 = ""; - $authorisation_or_completed_payment2 = ""; - switch( $authorisation_or_completed_payment ) { - case 1: - $authorisation_or_completed_payment1 = "checked= 'checked'"; - break; - - case 0: - default: - $authorisation_or_completed_payment2 = "checked='checked'"; - break; - } $output .= " - " . __( "IPN", 'wp-e-commerce' ) . ": @@ -809,21 +781,8 @@ function form_paypal_multiple() { " . __( "This setting affects your PayPal purchase log. If your customers already have a PayPal account, PayPal will try to populate your PayPal Purchase Log with their PayPal address. This setting tries to replace the address in the PayPal purchase log with the address customers enter on your Checkout page.", 'wp-e-commerce' ) . "

- - - - - " . __( 'Payment Authorisations:', 'wp-e-commerce' ) . " - - -   - -

- " . __( "This setting allows you to choose if you with to have PayPal payments come through as authorisations, or completed payments. Tick yes for payments to come through as authorisations, or no for payments to come through as completed payments. If set to authorisations, you will then be able to capture or void the transaction from within your PayPal account.", 'wp-e-commerce' ) . " -

- - \n"; - + \n"; + $store_currency_data = WPSC_Countries::get_currency_data( get_option( 'currency_type' ), true ); $current_currency = get_option('paypal_curcode'); if ( ( $current_currency == '' ) && in_array( $store_currency_data['code'], $wpsc_gateways['wpsc_merchant_paypal_standard']['supported_currencies']['currency_list'] ) ) { From 237ccbfad1b19e5c5f5e225c531b60e9c13344ac Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 18 Feb 2021 12:32:20 +0000 Subject: [PATCH 05/17] Please ignore Revert "Set PayPal payments to authorisations" Please ignore above revert. Done in error. Apologies. --- .../theme-engine-v1/helpers/product.php | 2 +- .../widgets/latest_product_widget.php | 2 +- .../widgets/specials_widget.php | 4 ++ wpsc-core/wpsc-deprecated.php | 2 +- wpsc-includes/cart-template-api.php | 2 +- wpsc-includes/meta.functions.php | 8 ++- wpsc-merchants/paypal-standard.merchant.php | 59 ++++++++++++++++--- 7 files changed, 64 insertions(+), 15 deletions(-) diff --git a/wpsc-components/theme-engine-v1/helpers/product.php b/wpsc-components/theme-engine-v1/helpers/product.php index 3d65ea9792..b8bad28122 100644 --- a/wpsc-components/theme-engine-v1/helpers/product.php +++ b/wpsc-components/theme-engine-v1/helpers/product.php @@ -158,7 +158,7 @@ function wpsc_list_categories($callback_function, $parameters = null, $category_ * Gets the Function Parent Image link and checks whether Image should be displayed or not * */ -function wpsc_parent_category_image($show_thumbnails , $category_image , $width, $height, $show_name, $grid=false ){ +function wpsc_parent_category_image($show_thumbnails , $category_image , $width, $height, $grid=false, $show_name){ if(!$show_thumbnails) return; diff --git a/wpsc-components/theme-engine-v1/widgets/latest_product_widget.php b/wpsc-components/theme-engine-v1/widgets/latest_product_widget.php index af241f1158..87b739f5d5 100755 --- a/wpsc-components/theme-engine-v1/widgets/latest_product_widget.php +++ b/wpsc-components/theme-engine-v1/widgets/latest_product_widget.php @@ -115,7 +115,7 @@ function form( $instance ) { return register_widget( 'WP_Widget_Latest_Products' ); } ); -function wpsc_latest_product( $args, $instance ) { +function wpsc_latest_product( $args = null, $instance ) { global $wpdb; $args = wp_parse_args( (array)$args, array( 'number' => 5 ) ); $options = get_option( 'wpsc-widget_latest_products' ); diff --git a/wpsc-components/theme-engine-v1/widgets/specials_widget.php b/wpsc-components/theme-engine-v1/widgets/specials_widget.php index 23f523a8b5..4faaa00ffa 100755 --- a/wpsc-components/theme-engine-v1/widgets/specials_widget.php +++ b/wpsc-components/theme-engine-v1/widgets/specials_widget.php @@ -170,7 +170,11 @@ function _wpsc_filter_special_widget_join( $join ) { * 5. Function now expect a single paramter with an array of options (used to be a string which prepended the output). */ +<<<<<<< HEAD function wpsc_specials( $args, $instance ) { +======= +function wpsc_specials( $args = null, $instance ) { +>>>>>>> parent of eb244fad (PHP 8 Compatibility) global $wpdb; diff --git a/wpsc-core/wpsc-deprecated.php b/wpsc-core/wpsc-deprecated.php index dae8c5493e..f64cf715c6 100644 --- a/wpsc-core/wpsc-deprecated.php +++ b/wpsc-core/wpsc-deprecated.php @@ -89,7 +89,7 @@ function nzshpcrt_donations($args){ * 4. The product list is enclosed in a
with a 'wpec-latest-products' class. * 5. Function now expects two arrays as per the standard Widget API. */ -function nzshpcrt_latest_product( $args, $instance ) { +function nzshpcrt_latest_product( $args = null, $instance ) { _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_latest_product'); echo wpsc_latest_product( $args, $instance ); } diff --git a/wpsc-includes/cart-template-api.php b/wpsc-includes/cart-template-api.php index 389445a6f9..b7e7e656de 100644 --- a/wpsc-includes/cart-template-api.php +++ b/wpsc-includes/cart-template-api.php @@ -469,7 +469,7 @@ function _wpsc_validate_cart_product_quantity( $product_id, $parameters, $cart ) * @return array of shipping options */ function wpsc_selfURL() { - $s = empty( $_SERVER ['HTTPS'] ) ? '' : (( $_SERVER ['HTTPS'] == 'on' ) ? 's' : ''); + $s = empty( $_SERVER ['HTTPS'] ) ? '' : ( $_SERVER ['HTTPS'] == 'on' ) ? 's' : ''; $protocol = wpsc_strleft( strtolower( $_SERVER ['SERVER_PROTOCOL'] ), '/' ) . $s; $port = ( $_SERVER ['SERVER_PORT'] == '80' ) ? '' : ( ':' . $_SERVER ['SERVER_PORT'] ); return $protocol . '://' . $_SERVER ['SERVER_NAME'] . $port . $_SERVER ['REQUEST_URI']; diff --git a/wpsc-includes/meta.functions.php b/wpsc-includes/meta.functions.php index 7704d80527..6255c0e254 100755 --- a/wpsc-includes/meta.functions.php +++ b/wpsc-includes/meta.functions.php @@ -21,7 +21,11 @@ function wpsc_sanitize_meta_key( $key ) { * @param string $object_type Object type. * @return mixed Meta value. */ +<<<<<<< HEAD function wpsc_get_meta( $object_id, $meta_key, $object_type ) { +======= +function wpsc_get_meta( $object_id = 0, $meta_key, $object_type ) { +>>>>>>> parent of eb244fad (PHP 8 Compatibility) global $wpdb; @@ -60,7 +64,7 @@ function wpsc_get_meta( $object_id, $meta_key, $object_type ) { * @param boolean $global ? * @return boolean */ -function wpsc_update_meta( $object_id, $meta_key, $meta_value, $object_type, $global = false ) { +function wpsc_update_meta( $object_id = 0, $meta_key, $meta_value, $object_type, $global = false ) { global $wpdb; @@ -105,7 +109,7 @@ function wpsc_update_meta( $object_id, $meta_key, $meta_value, $object_type, $gl * @param boolean $global ? * @return boolean */ -function wpsc_delete_meta( $object_id, $meta_key, $meta_value, $object_type, $global = false ) { +function wpsc_delete_meta( $object_id = 0, $meta_key, $meta_value, $object_type, $global = false ) { global $wpdb; diff --git a/wpsc-merchants/paypal-standard.merchant.php b/wpsc-merchants/paypal-standard.merchant.php index 137aa2ee1c..ed766fb8d4 100755 --- a/wpsc-merchants/paypal-standard.merchant.php +++ b/wpsc-merchants/paypal-standard.merchant.php @@ -125,10 +125,18 @@ function _construct_value_array( $aggregate = false ) { 'currency_code' => $this->get_paypal_currency_code(), 'lc' => $this->cart_data['store_currency'], 'no_note' => '1', - 'charset' => 'utf-8', - ); - - // IPN data + 'charset' => 'utf-8', + + ); + + // Set PayPal payments to come through as authorisations + if (get_option('authorisation_or_completed_payment') == 1) { + $paypal_vars += array( + 'paymentaction' => 'authorization' + ); + } + + // IPN data if (get_option('paypal_ipn') == 1) { $notify_url = $this->cart_data['notification_url']; $notify_url = add_query_arg('gateway', 'wpsc_merchant_paypal_standard', $notify_url); @@ -170,9 +178,10 @@ function _construct_value_array( $aggregate = false ) { // Order settings to be sent to paypal $paypal_vars += array( 'invoice' => $this->cart_data['session_id'] + ); - - if ( $buy_now ) { + + if ( $buy_now ) { $paypal_vars['custom'] = 'buy_now'; } @@ -651,11 +660,15 @@ function submit_paypal_multiple (){ update_option( 'paypal_ship', (int) $_POST['paypal_ship'] ); } + if ( isset( $_POST['authorisation_or_completed_payment'] ) ) { + update_option( 'authorisation_or_completed_payment', (int) $_POST['authorisation_or_completed_payment'] ); + } + if ( ! isset( $_POST['paypal_form'] ) ) { $_POST['paypal_form'] = array(); } - foreach( (array) $_POST['paypal_form'] as $form => $value ) { + foreach( (array) $_POST['paypal_form'] as $form => $value ) { update_option( 'paypal_form_' . $form, sanitize_text_field( $value ) ); } @@ -749,7 +762,22 @@ function form_paypal_multiple() { $address_override2 = "checked='checked'"; break; } + + $authorisation_or_completed_payment = get_option( 'authorisation_or_completed_payment' ); + $authorisation_or_completed_payment1 = ""; + $authorisation_or_completed_payment2 = ""; + switch( $authorisation_or_completed_payment ) { + case 1: + $authorisation_or_completed_payment1 = "checked= 'checked'"; + break; + + case 0: + default: + $authorisation_or_completed_payment2 = "checked='checked'"; + break; + } $output .= " + " . __( "IPN", 'wp-e-commerce' ) . ": @@ -781,8 +809,21 @@ function form_paypal_multiple() { " . __( "This setting affects your PayPal purchase log. If your customers already have a PayPal account, PayPal will try to populate your PayPal Purchase Log with their PayPal address. This setting tries to replace the address in the PayPal purchase log with the address customers enter on your Checkout page.", 'wp-e-commerce' ) . "

- \n"; - + + + + + " . __( 'Payment Authorisations:', 'wp-e-commerce' ) . " + + +   + +

+ " . __( "This setting allows you to choose if you with to have PayPal payments come through as authorisations, or completed payments. Tick yes for payments to come through as authorisations, or no for payments to come through as completed payments. If set to authorisations, you will then be able to capture or void the transaction from within your PayPal account.", 'wp-e-commerce' ) . " +

+ + \n"; + $store_currency_data = WPSC_Countries::get_currency_data( get_option( 'currency_type' ), true ); $current_currency = get_option('paypal_curcode'); if ( ( $current_currency == '' ) && in_array( $store_currency_data['code'], $wpsc_gateways['wpsc_merchant_paypal_standard']['supported_currencies']['currency_list'] ) ) { From 7f1a916d71f51be54522b58c29f508aad84986fc Mon Sep 17 00:00:00 2001 From: andy-1977 <61007039+andy-1977@users.noreply.github.com> Date: Thu, 18 Feb 2021 13:27:04 +0000 Subject: [PATCH 06/17] Delete product.php --- .../theme-engine-v1/helpers/product.php | 848 ------------------ 1 file changed, 848 deletions(-) delete mode 100644 wpsc-components/theme-engine-v1/helpers/product.php diff --git a/wpsc-components/theme-engine-v1/helpers/product.php b/wpsc-components/theme-engine-v1/helpers/product.php deleted file mode 100644 index b8bad28122..0000000000 --- a/wpsc-components/theme-engine-v1/helpers/product.php +++ /dev/null @@ -1,848 +0,0 @@ -ID; - } else { - // In wordpress 3.0 we get a post ID - $post_id = $post; - $post = get_post( $post_id ); - } - - // Only applies to WPSC products, don't stop on permalinks of other CPTs - // Fixes http://code.google.com/p/wp-e-commerce/issues/detail?id=271 - if ( 'wpsc-product' !== $post->post_type ) { - return $permalink; - } - - if ( 'inherit' === $post->post_status && 0 !== $post->post_parent ) { - $post_id = $post->post_parent; - $post = get_post( $post_id ); - } - - global $wp_rewrite; - - $our_permalink_structure = $wp_rewrite->root; - - // This may become customiseable later - $our_permalink_structure .= str_replace( basename( home_url() ), '', $wpsc_page_titles['products'] ) . "/%wpsc_product_category%/%postname%/"; - - // Mostly the same conditions used for posts, but restricted to items with a post type of "wpsc-product " - if ( $wp_rewrite->using_permalinks() && ! in_array( $post->post_status, array( 'draft', 'pending' ) ) ) { - - $product_categories = wpsc_get_product_terms( $post_id, 'wpsc_product_category' ); - $product_category_slugs = array( ); - foreach ( $product_categories as $product_category ) { - $product_category_slugs[] = $product_category->slug; - } - // If the product is associated with multiple categories, determine which one to pick - if ( count( $product_categories ) == 0 ) { - $category_slug = apply_filters( 'wpsc_uncategorized_product_category', 'uncategorized' ); - } elseif ( count( $product_categories ) > 1 ) { - if ( (isset( $wp_query->query_vars['products'] ) && $wp_query->query_vars['products'] != null) && in_array( $wp_query->query_vars['products'], $product_category_slugs ) ) { - $product_category = $wp_query->query_vars['products']; - } else { - $link = $product_categories[0]->slug; - if ( ! in_array( 'wp_head', $wp_current_filter) && isset( $wpsc_query->query_vars['wpsc_product_category'] ) ) { - $current_cat = $wpsc_query->query_vars['wpsc_product_category']; - if ( in_array( $current_cat, $product_category_slugs ) ) - $link = $current_cat; - } - - $product_category = $link; - } - $category_slug = $product_category; - } else { - // If the product is associated with only one category, we only have one choice - if ( !isset( $product_categories[0] ) ) - $product_categories[0] = ''; - - $product_category = $product_categories[0]; - - if ( !is_object( $product_category ) ) - $product_category = new stdClass(); - - if ( !isset( $product_category->slug ) ) - $product_category->slug = null; - - $category_slug = $product_category->slug; - } - - $post_name = $post->post_name; - - if ( get_option( 'product_category_hierarchical_url', 0 ) ) { - $selected_term = get_term_by( 'slug', $category_slug, 'wpsc_product_category' ); - if ( is_object( $selected_term ) ) { - $term_chain = array( $selected_term->slug ); - while ( $selected_term->parent ) { - $selected_term = get_term( $selected_term->parent, 'wpsc_product_category' ); - array_unshift( $term_chain, $selected_term->slug ); - } - $category_slug = implode( '/', $term_chain ); - } - } - - if( isset( $category_slug ) && empty( $category_slug ) ) - $category_slug = 'product'; - - $category_slug = apply_filters( 'wpsc_product_permalink_cat_slug', $category_slug, $post_id ); - - $rewritereplace = array( - $category_slug, - $post_name - ); - - $permalink = str_replace( $rewritecode, $rewritereplace, $our_permalink_structure ); - $permalink = user_trailingslashit( $permalink, 'single' ); - - $permalink = home_url( $permalink ); - } - - return apply_filters( 'wpsc_product_permalink', $permalink, $post->ID ); -} - -/** - * wpsc_list_categories function. - * - * @access public - * @param string $callback_function - The function name you want to use for displaying the data - * @param mixed $parameters (default: null) - the additional parameters to the callback function - * @param int $category_id. (default: 0) - The category id defaults to zero, for displaying all categories - * @param int $level. (default: 0) - */ -function wpsc_list_categories($callback_function, $parameters = null, $category_id = 0, $level = 0) { - global $wpdb,$category_data; - $output = ''; - $category_list = get_terms('wpsc_product_category','hide_empty=0&parent='.$category_id); - if($category_list != null) { - foreach((array)$category_list as $category) { - $callback_output = $callback_function($category, $level, $parameters); - if(is_array($callback_output)) { - $output .= array_shift($callback_output); - } else { - $output .= $callback_output; - } - $output .= wpsc_list_categories($callback_function, $parameters , $category->term_id, ($level+1)); - if(is_array($callback_output) && (isset($callback_output[1]))) { - $output .= $callback_output[1]; - } - } - } - return $output; -} - -/** -* Gets the Function Parent Image link and checks whether Image should be displayed or not -* -*/ -function wpsc_parent_category_image($show_thumbnails , $category_image , $width, $height, $grid=false, $show_name){ - - if(!$show_thumbnails) return; - - if($category_image == WPSC_CATEGORY_URL){ - if(!$show_name) return; - ?> - - - - - - $start_element, 'end_element' => $end_element); - echo "[wpsc_category_description]"; -} - -/** -* wpsc print category url function -* places the shortcode for the category URL -*/ -function wpsc_print_category_url() { - echo "[wpsc_category_url]"; -} - -/** -* wpsc print category id function -* places the shortcode for the category URL -*/ -function wpsc_print_category_id() { - echo "[wpsc_category_id]"; -} - -/** -* wpsc print category classes function -* places classes for the category including selected state -* -* please note that "current category" means the category that we are in now, -* and not the category that we are printing for -* -* @param $category_to_print - the category for which we should print classes -* @param $echo - whether to echo the result (true) or return (false) -*/ -function wpsc_print_category_classes($category_to_print = false, $echo = true) { - global $wp_query, $wpdb; - $result = ''; - - //if we are in wpsc category page then get the current category - $curr_cat = false; - $term = get_query_var( 'wpsc_product_category' ); - if ( ! $term && get_query_var( 'taxonomy' ) == 'wpsc_product_category' ) - $term = get_query_var( 'term' ); - if ( $term ) - $curr_cat = get_term_by( 'slug', $term, 'wpsc_product_category' ); - - //check if we are in wpsc category page and that we have a term_id of the category to print - //this is done here because none of the following matters if we don't have one of those and we can - //safely return - if(isset($category_to_print['term_id']) && $curr_cat){ - - //we will need a list of current category parents for the following if statement - $curr_cat_parents = wpsc_get_term_parents($curr_cat->term_id, 'wpsc_product_category'); - - //if current category is the same as the one we are printing - then add wpsc-current-cat class - if( $category_to_print['term_id'] == $curr_cat->term_id ) - $result = ' wpsc-current-cat '; - //else check if the category that we are printing is parent of current category - elseif ( in_array($category_to_print['term_id'], $curr_cat_parents) ) - $result = ' wpsc-cat-ancestor '; - } - - $result = apply_filters( 'wpsc_print_category_classes', $result, $category_to_print ); - - if ( ! empty ( $result ) ) { - if ( $echo ) { - echo $result; - } else { - return $result; - } - } -} - -/** -* wpsc print subcategory function -* places the shortcode for the subcategories, accepts parameters for the subcategories container, have this as
    and
if using a list -* @param string starting HTML element -* @param string ending HTML element -*/ -function wpsc_print_subcategory($start_element = '', $end_element = '') { - global $wpsc_category_query; - $wpsc_category_query['subcategory_container'] = array('start_element' => $start_element, 'end_element' => $end_element); - echo "[wpsc_subcategory]"; -} -function wpsc_print_category_classes_section(){ - echo "[wpsc_category_classes]"; -} - -/** -* wpsc print category image function -* places the shortcode for the category image, accepts parameters for width and height -* @param integer width -* @param integer height -*/ -function wpsc_print_category_image($width = null, $height = null) { - global $wpsc_category_query; - $wpsc_category_query['image_size'] = array('width' => $width, 'height' => $height); - echo "[wpsc_category_image]"; -} - -/** -* wpsc print category products count function -* places the shortcode for the category product count, accepts parameters for the container element -* @param string starting HTML element -* @param string ending HTML element -*/ -function wpsc_print_category_products_count($start_element = '', $end_element = '') { - global $wpsc_category_query; - $wpsc_category_query['products_count'] = array('start_element' => $start_element, 'end_element' => $end_element); - echo "[wpsc_category_products_count]"; -} - -/** -* wpsc end category query function -*/ -function wpsc_end_category_query() { - global $wpdb, $wpsc_category_query; - $category_html = ob_get_clean(); - echo wpsc_display_category_loop($wpsc_category_query, $category_html); - unset($GLOBALS['wpsc_category_query']); -} - -/** -* wpsc category loop function -* This function recursively loops through the categories to display the category tree. -* This function also generates a tree of categories at the same time -* WARNING: as this function is recursive, be careful what you do with it. -* @param array the category query -* @param string the category html -* @param array the category array branch, is an internal value, leave it alone. -* @return string - the finished category html -*/ -function wpsc_display_category_loop($query, $category_html, &$category_branch = null){ - static $category_count_data = array(); // the array tree is stored in this - - if( isset($query['parent_category_id']) ) - $category_id = absint($query['parent_category_id']); - else - $category_id = 0; - $category_data = get_terms('wpsc_product_category','hide_empty=0&parent='.$category_id, OBJECT, 'display'); - $output =''; - - // if the category branch is identical to null, make it a reference to $category_count_data - if($category_branch === null) { - $category_branch =& $category_count_data; - } - $allowed_tags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array(), 'b'=> array()); - - $allowedtags = apply_filters('wpsc_category_description_allowed_tags' , $allowed_tags); - - foreach((array)$category_data as $category_row) { - - // modifys the query for the next round - $modified_query = $query; - $modified_query['parent_category_id'] = $category_row->term_id; - - // gets the count of products associated with this category - $category_count = $category_row->count; - - - // Sticks the category description in - $category_description = ''; - if($category_row->description != '' && ! empty( $query['description_container'] ) ) { - $start_element = $query['description_container']['start_element']; - $end_element = $query['description_container']['end_element']; - $category_description = $start_element.wpautop(wptexturize( wp_kses( $category_row->description, $allowedtags ))).$end_element; - } - - - // Creates the list of classes on the category item - $category_classes = wpsc_print_category_classes((array)$category_row, false); - - // Set the variables for this category - $category_branch[$category_row->term_id]['children'] = array(); - $category_branch[$category_row->term_id]['count'] = (int)$category_count; - - - // Recurse into the next level of categories - $sub_categories = wpsc_display_category_loop($modified_query, $category_html, $category_branch[$category_row->term_id]['children']); - - // grab the product count from the subcategories - foreach((array)$category_branch[$category_row->term_id]['children'] as $child_category) { - $category_branch[$category_row->term_id]['count'] += (int)$child_category['count']; - } - - // stick the category count array together here - // this must run after the subcategories and the count of products belonging to them has been obtained - - $category_count = $category_branch[$category_row->term_id]['count']; - - $start_element = ''; - $end_element = ''; - - if (isset($query['products_count']['start_element'])) { - $start_element = $query['products_count']['start_element']; - } - - if (isset($query['products_count']['end_element'])) { - $end_element = $query['products_count']['end_element']; - } - - $category_count_html = $start_element.$category_count.$end_element; - - - if ( isset( $query['subcategory_container'] ) && ! empty( $sub_categories ) ) { - $start_element = $query['subcategory_container']['start_element']; - $end_element = $query['subcategory_container']['end_element']; - $sub_categories = $start_element.$sub_categories.$end_element; - } - - // get the category images - $category_image = wpsc_place_category_image($category_row->term_id, $modified_query); - - if ( empty( $query['image_size']['width'] ) ) { - if ( ! wpsc_category_grid_view() ) - $width = wpsc_get_categorymeta( $category_row->term_id, 'image_width' ); - if ( empty( $width ) ) - $width = get_option( 'category_image_width' ); - } else { - $width = $query['image_size']['width']; - } - - if ( empty( $query['image_size']['height'] ) ) { - if ( ! wpsc_category_grid_view() ) - $height = wpsc_get_categorymeta( $category_row->term_id, 'image_height' ); - if ( empty( $height ) ) - $height = get_option( 'category_image_height' ); - } else { - $height = $query['image_size']['height']; - } - - $category_image = wpsc_get_categorymeta($category_row->term_id, 'image'); - $category_image_html = ''; - if(($query['show_thumbnails'] == 1)) { - if((!empty($category_image)) && is_file(WPSC_CATEGORY_DIR.$category_image)) { - $category_image_html = "{$category_row->name}"; - } elseif( isset( $query['show_name'] ) && 1 == $query['show_name']) { - $category_image_html .= "\n\r"; - $category_image_html .= " \n\r"; - $category_image_html .= " ".__('N/A','wp-e-commerce')."\n\r"; - $category_image_html .= " \n\r"; - $category_image_html .= "\n\r"; - } - - } - - - // get the list of products associated with this category. - $tags_to_replace = array('[wpsc_category_name]', - '[wpsc_category_description]', - '[wpsc_category_url]', - '[wpsc_category_id]', - '[wpsc_category_classes]', - '[wpsc_category_image]', - '[wpsc_subcategory]', - '[wpsc_category_products_count]'); - - $content_to_place = array( - esc_html($category_row->name), - $category_description, - esc_url( get_term_link( $category_row->slug, 'wpsc_product_category' ) ), - $category_row->term_id, - $category_classes, - $category_image_html, - $sub_categories, - $category_count_html); - - // Stick all the category html together and concatenate it to the previously generated HTML - $output .= str_replace($tags_to_replace, $content_to_place ,$category_html); - } - return $output; -} - -/** -* wpsc category image function -* if no parameters are passed, the category is not resized, otherwise it is resized to the specified dimensions -* @param integer category id -* @param array category query array -* @return string - the category image URL, or the URL of the resized version -*/ -function wpsc_place_category_image($category_id, $query) { - // show the full sized image for the product, if supplied with dimensions, will resize image to those. - $width = (isset($query['image_size']['width'])) ? ($query['image_size']['width']) : get_option('category_image_width'); - $height = (isset($query['image_size']['height'])) ? ($query['image_size']['height']) : get_option('category_image_height'); - $image_url = "index.php?wpsc_request_image=true&category_id=".$category_id."&width=".$width."&height=".$height; - return htmlspecialchars($image_url); -} - -/// category template tags end here - -/** -* wpsc_category_url function, makes permalink to the category or -* @param integer category ID, can be 0 -* @param boolean permalink compatibility, adds a prefix to prevent permalink namespace conflicts -*/ -function wpsc_category_url($category_id, $permalink_compatibility = false) { - return get_term_link( $category_id, 'wpsc_product_category'); -} - - -/** - * Returns true if you're on a category that is a WPeC category - * - * @uses is_tax() Returns true/false given taxonomy and takes second parameter of term - * @param string|array|int $term optional The term you could be checking for - * @return bool True if you are on a wpsc_product_category false if not - */ -function wpsc_is_in_category( $term = '' ) { - - return is_tax( 'wpsc_product_category', $term ); - -} - - -/** - * Uses a category's, (in the wpsc_product_category taxonomy), slug to find its - * ID, then returns it. - * - * @param string $category_slug The slug of the category who's ID we want. - * @return (int | bool) Returns the integer ID of the category if found, or a - * boolean false if the category is not found. - * - * @todo Cache the results of this somewhere. It could save quite a few trips - * to the MySQL server. - * - */ -function wpsc_category_id($category_slug = '') { - if(empty($category_slug)) - $category_slug = get_query_var( 'wpsc_product_category' ); - elseif(array_key_exists('wpsc_product_category', $_GET)) - $category_slug = $_GET['wpsc_product_category']; - - if(!empty($category_slug)) { - $category = get_term_by('slug', $category_slug, 'wpsc_product_category'); - if(!empty($category->term_id)){ - return $category->term_id; - } else { - return false; - } - } else { - return false; - } -} - -/** -* wpsc_category_description function, Gets the category description -* @param integer category ID, can be 0 -* @return string category description -*/ -function wpsc_category_description($category_id = null) { - if($category_id < 1) - $category_id = wpsc_category_id(); - $category = get_term_by( 'id', $category_id, 'wpsc_product_category' ); - return $category ? $category->description : ''; -} - -function wpsc_category_name($category_id = null) { - if ( $category_id < 1 ) - $category_id = wpsc_category_id(); - - $category = get_term_by( 'id', $category_id, 'wpsc_product_category' ); - return $category ? $category->name : ''; -} - -function nzshpcrt_display_categories_groups() { - return ''; -} - -/** wpsc list subcategories function - used to get an array of all the subcategories of a category. -*/ -function wpsc_list_subcategories($category_id = null) { - global $wpdb,$category_data; - - $category_list = $wpdb->get_col( $wpdb->prepare( "SELECT `id` FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `category_parent` = %d", $category_id ) ); - - if($category_list != null) { - foreach($category_list as $subcategory_id) { - $category_list = array_merge((array)$category_list, (array)wpsc_list_subcategories($subcategory_id)); - } - } - return $category_list; -} - -/** - * wpsc_show_category_thumbnails function - * @return bool - whether to show category thumbnails or not - */ -function wpsc_show_category_thumbnails(){ - if(get_option('show_category_thumbnails') && wpsc_category_image()) - return true; - else - return false; -} - -/** - * wpsc_show_category_description function - * @return bool - whether to show category description or not - */ -function wpsc_show_category_description(){ - return get_option( 'wpsc_category_description' ); -} - -/** - * wpsc buy now button code products function - * Sorry about the ugly code, this is just to get the functionality back, buy now will soon be overhauled, and this function will then be completely different - * @return string - html displaying one or more products - */ -function wpsc_buy_now_button( $product_id, $replaced_shortcode = false ) { - - $product_id = absint( $product_id ); - - $product = get_post( $product_id ); - $supported_gateways = array( 'wpsc_merchant_paypal_standard', 'paypal_multiple' ); - $selected_gateways = get_option( 'custom_gateway_options' ); - - if ( $replaced_shortcode ) { - ob_start(); - } - - if ( in_array( 'wpsc_merchant_paypal_standard', (array) $selected_gateways ) ) { - if ( $product_id > 0 ) { - - $post_meta = get_post_meta( $product_id, '_wpsc_product_metadata', true ); - $shipping = isset( $post_meta['shipping'] ) ? $post_meta['shipping']['local'] : ''; - $price = get_post_meta( $product_id, '_wpsc_price', true ); - $special_price = get_post_meta( $product_id, '_wpsc_special_price', true ); - - if ( $special_price ) - $price = $special_price; - - if ( wpsc_uses_shipping ( ) ) { - $handling = get_option( 'base_local_shipping' ); - } else { - $handling = $shipping; - } - - $has_variants = wpsc_product_has_variations( $product_id ) || ! wpsc_product_has_stock( $product_id ); - - $src = apply_filters( 'wpsc_buy_now_button_src', _x( 'https://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif', 'PayPal Buy Now Button', 'wp-e-commerce' ) ); - $classes = apply_filters( 'wpsc_buy_now_button_class', "wpsc-buy-now-form wpsc-buy-now-form-{$product_id}" ); - - $classes_array = array_map( 'sanitize_html_class', explode( ' ', $classes ) ); - - $classes = implode( ' ', $classes_array ); - - $button_html = sprintf( '', - disabled( $has_variants, true, false ), - esc_attr( $product_id ), - esc_url( $src ), - esc_attr__( 'PayPal - The safer, easier way to pay online', 'wp-e-commerce' ) - ); - - $button_html = apply_filters( 'wpsc_buy_now_button_html', $button_html, $product_id ); -?> -
- - -', wpsc_vargrp_id(), wpsc_vargrp_form_id() ); - endwhile; - endif; /* END wpsc_product_has_variations */ -?> - - -
- - - - - ' /> -
- get_results( $wpdb->prepare( "SELECT `" . $wpdb->posts . "`.* FROM `" . WPSC_TABLE_ALSO_BOUGHT . "`, `" . $wpdb->posts . "` WHERE `selected_product`= %d AND `" . WPSC_TABLE_ALSO_BOUGHT . "`.`associated_product` = `" . $wpdb->posts . "`.`id` AND `" . $wpdb->posts . "`.`post_status` IN('publish','protected') ORDER BY `" . WPSC_TABLE_ALSO_BOUGHT . "`.`quantity` DESC LIMIT $also_bought_limit", $product_id ), ARRAY_A ); - if ( is_array( $also_bought ) && count( $also_bought ) > 0 ) { - $output .= '

' . __( 'People who bought this item also bought', 'wp-e-commerce' ) . '

'; - $output .= '
'; - foreach ( $also_bought as $also_bought_data ) { - $output .= '
'; - if ( get_option( 'show_thumbnails' ) == 1 ) { - $image_path = wpsc_the_product_thumbnail( $image_display_width, $image_display_height, $also_bought_data['ID'] ); - if ( $image_path ) { - $output .= ''; - $output .= ''; - $output .= ''; - } else { - if ( get_option( 'product_image_width' ) != '' ) { - $width_and_height = 'width="' . $image_display_height . '" height="' . $image_display_height . '" '; - } else { - $width_and_height = ''; - } - $output .= '' . esc_attr( get_the_title( $also_bought_data['ID'] ) ) . ''; - } - } - - $output .= '' . get_the_title( $also_bought_data['ID'] ) . ''; - if ( ! wpsc_product_is_donation( $also_bought_data['ID'] ) ) { - // Ideally use the wpsc_the_product_price_display() function here but needs some tweaking - $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 .= '' . wpsc_currency_display( $price ) . ''; - $output .= wpsc_currency_display( $special_price ); - } else { - $output .= wpsc_currency_display( $price ); - } - } - $output .= '
'; - } - $output .= '
'; - $output .= '
'; - } - return $output; -} - -/** - * Get the URL of the loading animation image. - * Can be filtered using the wpsc_loading_animation_url filter. - */ -function wpsc_loading_animation_url() { - return apply_filters( 'wpsc_loading_animation_url', WPSC_CORE_THEME_URL . 'wpsc-images/indicator.gif' ); -} - -/* - * wpsc product url function, gets the URL of a product, - * Deprecated, all parameters past the first unused. use get_permalink - */ - -function wpsc_product_url( $product_id, $category_id = null, $escape = true ) { - $post = get_post($product_id); - if ( isset($post->post_parent) && $post->post_parent > 0) { - return get_permalink($post->post_parent); - } else { - return get_permalink($product_id); - } -} - -function external_link( $product_id ) { - $link = get_product_meta( $product_id, 'external_link', true ); - if ( !stristr( $link, 'http://' ) ) { - $link = 'http://' . $link; - } - $target = wpsc_product_external_link_target( $product_id ); - $output .= ""; - return $output; -} - -/** - * wpsc_refresh_page_urls - * - * Refresh page urls when pages are updated - * - * @param int $post_id - * @param object $post - * @uses wpsc_update_permalink_slugs() - * @return int $post_id - */ -function wpsc_refresh_page_urls( $post_id, $post ) { - - if ( ! current_user_can( 'manage_options' ) ) - return; - - if ( 'page' != $post->post_type ) - return; - - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) - return; - - if ( ! in_array( $post->post_status, array( 'publish', 'private' ) ) ) - return; - - wpsc_update_permalink_slugs(); - - return $post_id; -} - -function wpsc_replace_wp_title( $input ) { - global $wpdb, $wp_query; - $output = wpsc_obtain_the_title(); - if ( $output != null ) { - return $output; - } - return $input; -} - -function wpsc_replace_bloginfo_title( $input, $show ) { - global $wpdb, $wp_query; - if ( $show == 'description' ) { - $output = wpsc_obtain_the_title(); - if ( $output != null ) { - return $output; - } - } - return $input; -} - From cb452476a1df8e95e990e4eaf939292f509a868b Mon Sep 17 00:00:00 2001 From: andy-1977 <61007039+andy-1977@users.noreply.github.com> Date: Thu, 18 Feb 2021 13:27:18 +0000 Subject: [PATCH 07/17] Delete specials_widget.php --- .../widgets/specials_widget.php | 251 ------------------ 1 file changed, 251 deletions(-) delete mode 100755 wpsc-components/theme-engine-v1/widgets/specials_widget.php diff --git a/wpsc-components/theme-engine-v1/widgets/specials_widget.php b/wpsc-components/theme-engine-v1/widgets/specials_widget.php deleted file mode 100755 index 4faaa00ffa..0000000000 --- a/wpsc-components/theme-engine-v1/widgets/specials_widget.php +++ /dev/null @@ -1,251 +0,0 @@ - 'widget_wpsc_product_specials', - 'description' => __( 'Product Specials Widget', 'wp-e-commerce' ) - ); - - parent::__construct( 'wpsc_product_specials', __( '(WPEC) Product Specials', 'wp-e-commerce' ), $widget_ops ); - - } - - /** - * Widget Output - * - * @param $args (array) - * @param $instance (array) Widget values. - * - * @todo Add individual capability checks for each menu item rather than just manage_options. - */ - public function widget( $args, $instance ) { - - global $wpdb, $table_prefix; - - extract( $args ); - - echo $before_widget; - $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Product Specials', 'wp-e-commerce' ) : $instance['title'] ); - if ( $title ) - echo $before_title . $title . $after_title; - - wpsc_specials( $args, $instance ); - echo $after_widget; - - } - - /** - * Update Widget - * - * @param $new_instance (array) New widget values. - * @param $old_instance (array) Old widget values. - * - * @return (array) New values. - */ - public function update( $new_instance, $old_instance ) { - - $instance = $old_instance; - $instance['title'] = strip_tags( $new_instance['title'] ); - $instance['number'] = (int) $new_instance['number']; - $instance['show_thumbnails'] = (bool) $new_instance['show_thumbnails']; - $instance['show_description'] = (bool) $new_instance['show_description']; - $instance['show_old_price'] = (bool) $new_instance['show_old_price']; - $instance['show_discount'] = (bool) $new_instance['show_discount']; - - return $instance; - - } - - /** - * Widget Options Form - * - * @param $instance (array) Widget values. - */ - public function form( $instance ) { - - global $wpdb; - - // Defaults - $instance = wp_parse_args( (array) $instance, array( - 'title' => '', - 'show_description' => false, - 'show_thumbnails' => false, - 'number' => 5, - 'show_old_price' => false, - 'show_discount' => false, - ) ); - - // Values - $title = esc_attr( $instance['title'] ); - $number = (int) $instance['number']; - $show_thumbnails = (bool) $instance['show_thumbnails']; - $show_description = (bool) $instance['show_description']; - $show_discount = (bool) $instance['show_discount']; - $show_old_price = (bool) $instance['show_old_price']; - - ?> -

- - -

-

- - -

-

- > -
- > -
- > -
- > - -

-posts} AS p - INNER JOIN {$wpdb->postmeta} AS pm - ON p.ID = pm.post_id AND pm.meta_key = '_wpsc_special_price' AND pm.meta_value > 0 - WHERE p.post_parent != 0 AND p.post_status IN ('publish', 'inherit') - "; - - $parent_ids = $wpdb->get_col( $sql ); - - if ( $parent_ids ) { - $parent_ids = array_map( 'absint', $parent_ids ); - $where .= " AND ({$wpdb->posts}.ID IN (" . implode( ', ', $parent_ids ) . ") OR pm.meta_value > 0) "; - } else { - $where .= " AND pm.meta_value > 0 "; - } - - return $where; -} - -function _wpsc_filter_special_widget_join( $join ) { - global $wpdb; - $join .= " INNER JOIN {$wpdb->postmeta} AS pm ON {$wpdb->posts}.ID = pm.post_id AND pm.meta_key = '_wpsc_special_price' "; - return $join; -} - -/** - * Product Specials Widget content function - * - * Displays the latest products. - * - * Changes made in 3.8 that may affect users: - * - * 1. The product title link text does now not have a bold tag, it should be styled via css. - * 2.
tags have been ommitted. Padding and margins should be applied via css. - * 3. Each product is enclosed in a
with a 'wpec-special-product' class. - * 4. The product list is enclosed in a
with a 'wpec-special-products' class. - * 5. Function now expect a single paramter with an array of options (used to be a string which prepended the output). - */ - -<<<<<<< HEAD -function wpsc_specials( $args, $instance ) { -======= -function wpsc_specials( $args = null, $instance ) { ->>>>>>> parent of eb244fad (PHP 8 Compatibility) - - global $wpdb; - - $args = wp_parse_args( (array) $args, array( 'number' => 5 ) ); - - if ( ! $number = (int) $instance['number'] ) - $number = 5; - - $show_thumbnails = isset( $instance['show_thumbnails'] ) ? (bool) $instance['show_thumbnails'] : false; - $show_description = isset( $instance['show_description'] ) ? (bool) $instance['show_description'] : false; - $show_discount = isset( $instance['show_discount'] ) ? (bool) $instance['show_discount'] : false; - $show_old_price = isset( $instance['show_old_price'] ) ? (bool) $instance['show_old_price'] : false; - - $args = array( - 'post_type' => 'wpsc-product', - 'ignore_sticky_posts' => 1, - 'post_status' => 'publish', - 'post_parent' => 0, - 'posts_per_page' => $number, - 'no_found_rows' => true, - ); - - add_filter( 'posts_join', '_wpsc_filter_special_widget_join' ); - add_filter( 'posts_where', '_wpsc_filter_special_widget_where' ); - $special_products = new WP_Query( $args ); - remove_filter( 'posts_join', '_wpsc_filter_special_widget_join' ); - remove_filter( 'posts_where', '_wpsc_filter_special_widget_where' ); - - if ( ! $special_products->post_count ) { - echo apply_filters( 'wpsc_specials_widget_no_items_message', __( 'We currently have no items on special.', 'wp-e-commerce' ) ); - return; - } - - $product_ids = array(); - - while ( $special_products->have_posts() ) : - $special_products->the_post(); - ?> -

- - -
- -
- - " href=""><?php echo esc_attr( wpsc_the_product_title() ); ?> - - <?php echo esc_attr( wpsc_the_product_title() ); ?> - -
- -
- $show_old_price, - 'output_you_save' => $show_discount, - ) - ); - ?> -

- Date: Thu, 18 Feb 2021 13:27:35 +0000 Subject: [PATCH 08/17] Delete meta.functions.php --- wpsc-includes/meta.functions.php | 387 ------------------------------- 1 file changed, 387 deletions(-) delete mode 100755 wpsc-includes/meta.functions.php diff --git a/wpsc-includes/meta.functions.php b/wpsc-includes/meta.functions.php deleted file mode 100755 index 6255c0e254..0000000000 --- a/wpsc-includes/meta.functions.php +++ /dev/null @@ -1,387 +0,0 @@ ->>>>>> parent of eb244fad (PHP 8 Compatibility) - - global $wpdb; - - $cache_object_id = $object_id = (int) $object_id; - $meta_key = wpsc_sanitize_meta_key( $meta_key ); - - $meta_tuple = compact( 'object_type', 'object_id', 'meta_key' ); - $meta_tuple = apply_filters( 'wpsc_get_meta', $meta_tuple ); - - // Get cached meta - $meta_value = wp_cache_get( $cache_object_id, $meta_tuple['object_type'] ); - - // If not cached, get and cache all object meta - if ( $meta_value === false ) { - $meta_values = wpsc_update_meta_cache( $meta_tuple['object_type'], $meta_tuple['object_id'] ); - $meta_value = $meta_values[ $meta_tuple['object_id'] ]; - } - - if ( isset( $meta_value[ $meta_tuple['meta_key'] ] ) ) { - return maybe_unserialize( $meta_value[ $meta_tuple['meta_key'] ] ); - } - - return ''; - -} - -/** - * Adds and updates meta data in the database - * - * @internal - * - * @param integer $object_id Object ID. - * @param string $meta_key Meta key. - * @param mixed $meta_value Meta value. - * @param string $object_type Object type. - * @param boolean $global ? - * @return boolean - */ -function wpsc_update_meta( $object_id = 0, $meta_key, $meta_value, $object_type, $global = false ) { - - global $wpdb; - - if ( ! is_numeric( $object_id ) || empty( $object_id ) && ! $global ) { - return false; - } - - $cache_object_id = $object_id = (int) $object_id; - $meta_key = wpsc_sanitize_meta_key( $meta_key ); - - $meta_tuple = compact( 'object_type', 'object_id', 'meta_key', 'meta_value' ); - $meta_tuple = apply_filters( 'wpsc_update_meta', $meta_tuple ); - - $meta_value = $_meta_value = maybe_serialize( $meta_tuple['meta_value'] ); - $meta_value = maybe_unserialize( $meta_value ); - - $cur = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_META . "` WHERE `object_type` = %s AND `object_id` = %d AND `meta_key` = %s", $meta_tuple['object_type'], $meta_tuple['object_id'], $meta_tuple['meta_key'] ) ); - - if ( ! $cur ) { - $wpdb->insert( WPSC_TABLE_META, array( 'object_type' => $meta_tuple['object_type'], 'object_id' => $meta_tuple['object_id'], 'meta_key' => $meta_tuple['meta_key'], 'meta_value' => $_meta_value ) ); - } elseif ( $cur->meta_value != $meta_value ) { - $wpdb->update( WPSC_TABLE_META, array( 'meta_value' => $_meta_value ), array( 'object_type' => $meta_tuple['object_type'], 'object_id' => $meta_tuple['object_id'], 'meta_key' => $meta_tuple['meta_key'] ) ); - } - - wp_cache_delete( $cache_object_id, $meta_tuple['object_type'] ); - - if ( ! $cur ) { - return true; - } - -} - -/** - * Deletes meta data from the database - * - * @internal - * - * @param integer $object_id Object ID. - * @param string $meta_key Meta key. - * @param mixed $meta_value Meta value. - * @param string $object_type Object type. - * @param boolean $global ? - * @return boolean - */ -function wpsc_delete_meta( $object_id = 0, $meta_key, $meta_value, $object_type, $global = false ) { - - global $wpdb; - - if ( ! is_numeric( $object_id ) || empty( $object_id ) && ! $global ) { - return false; - } - - $cache_object_id = $object_id = (int) $object_id; - $meta_key = wpsc_sanitize_meta_key( $meta_key ); - - $meta_tuple = compact( 'object_type', 'object_id', 'meta_key', 'meta_value' ); - $meta_tuple = apply_filters( 'wpsc_delete_meta', $meta_tuple ); - - $meta_value = maybe_serialize( $meta_tuple['meta_value'] ); - - if ( empty( $meta_value ) ) { - $meta_sql = $wpdb->prepare( "SELECT `meta_id` FROM `" . WPSC_TABLE_META . "` WHERE `object_type` = %s AND `object_id` = %d AND `meta_key` = %s", $meta_tuple['object_type'], $meta_tuple['object_id'], $meta_tuple['meta_key'] ); - } else { - $meta_sql = $wpdb->prepare( "SELECT `meta_id` FROM `" . WPSC_TABLE_META . "` WHERE `object_type` = %s AND `object_id` = %d AND `meta_key` = %s AND `meta_value` = %s", $meta_tuple['object_type'], $meta_tuple['object_id'], $meta_tuple['meta_key'], $meta_value ); - } - - if ( ! $meta_id = $wpdb->get_var( $meta_sql ) ) { - return false; - } - $wpdb->query( $wpdb->prepare( "DELETE FROM `" . WPSC_TABLE_META . "` WHERE `meta_id` = %d", $meta_id ) ); - - wp_cache_delete( $cache_object_id, $meta_tuple['object_type'] ); - - return true; - -} - -/** - * Update Meta Cache - * - * Query database to get meta for objects, update the cache and return the object meta. - * - * @param string $object_type Object type. - * @param int|array $object_ids Object ID or IDs. - * @return array Array of objects and cached values. - */ -function wpsc_update_meta_cache( $object_type, $object_ids ) { - - global $wpdb; - - if ( ! $object_type || ! $object_ids ) { - return false; - } - - // If $object_ids is a string, convert to array - if ( ! is_array( $object_ids ) ) { - $object_ids = preg_replace( '|[^0-9,]|', '', $object_ids ); - $object_ids = explode( ',', $object_ids ); - } - - $object_ids = array_map( 'intval', $object_ids ); - - $ids = array(); - $cache = array(); - - // Only need to retrieve objects that aren't already cached - foreach ( $object_ids as $id ) { - $cached_object = wp_cache_get( $id, $object_type ); - if ( false === $cached_object ) { - $ids[] = $id; - } else { - $cache[ $id ] = $cached_object; - } - } - - if ( empty( $ids ) ) { - return $cache; - } - - $id_list = join( ',', $ids ); - $meta_list = $wpdb->get_results( $wpdb->prepare( "SELECT object_id, meta_key, meta_value FROM " . WPSC_TABLE_META . " WHERE `object_type` = '%s' AND `object_id` IN ( " . $id_list . " )", $object_type ), ARRAY_A ); - - // Add results to cache array - if ( ! empty( $meta_list ) ) { - foreach ( $meta_list as $metarow ) { - $mpid = intval( $metarow[ 'object_id' ] ); - $mkey = $metarow['meta_key']; - $mval = $metarow['meta_value']; - - // Add a value to the current pid/key: - $cache[ $mpid ][ $mkey ] = $mval; - } - } - - // Update cache - foreach ( $ids as $id ) { - if ( ! isset( $cache[ $id ] ) ) { - $cache[ $id ] = array(); - } - wp_cache_add( $id, $cache[ $id ], $object_type ); - } - - return $cache; -} - -/** - * category meta functions are as follows: - */ - -/** - * Retrieve meta field for a category - * - * @param int $cat_id Category ID. - * @param string $meta_key The meta key to retrieve. - * @return mixed Will be value of meta data field - */ -function wpsc_get_categorymeta( $cat_id, $meta_key ) { - return wpsc_get_meta( $cat_id, $meta_key, 'wpsc_category' ); -} - -/** - * Update meta field for a category - * - * @param int $cat_id Category ID. - * @param string $meta_key The meta key to retrieve. - * @param string $meta_value The value to be stored. - * @return mixed True if updated - */ -function wpsc_update_categorymeta( $cat_id, $meta_key, $meta_value ) { - return wpsc_update_meta( $cat_id, $meta_key, $meta_value, 'wpsc_category' ); -} - -/** - * Delete meta field for a category - * - * @param int $cat_id Category ID. - * @param string $meta_key The meta key to retrieve. - * @param string $meta_value Value to be compared before deleting. - * @return mixed True if updated - */ -function wpsc_delete_categorymeta( $cat_id, $meta_key, $meta_value = '' ) { - return wpsc_delete_meta( $cat_id, $meta_key, $meta_value, 'wpsc_category' ); -} -/** - * category meta functions end here. - */ - - -/** - * product meta functions start here - * all these functions just prefix the key with the meta prefix, and pass the values through to the equivalent post meta function. - */ - -/** - * add_product_meta function. - * - * @access public - * @param int $product_id Unique product identifier - * @param string $key Metadata name. - * @param mixed $value Metadata value. Must be serializable if non-scalar. - * @param bool $unique - obsolete - * @param bool $custom - obsolete - * @return int|bool WordPress Meta ID on success, false on failure. - */ -function add_product_meta( $product_id, $key, $value, $unique = false, $custom = false ) { - $key = WPSC_META_PREFIX.$key; - return add_post_meta($product_id, $key, $value); -} - -/** - * delete_product_meta function. - * - * @access public - * @param int $product_id - * @param string $key - * @param mixed $value. Optional. Metadata value. Must be serializable if non-scalar. Default empty - * @return bool True on success, false on failure. - */ -function delete_product_meta($product_id, $key, $value = '') { - $key = WPSC_META_PREFIX.$key; - return delete_post_meta($product_id, $key, $value); -} - - -/** - * get_product_meta function. - * - * @access public - * @param int $product_id - * @param string $key - * @param bool $single Optional. Whether to return a single value. Default false. - * @return mixed Will be an array if $single is false. Will be value of meta data - * field if $single is true. - */ -function get_product_meta($product_id, $key, $single = false) { - $key = WPSC_META_PREFIX.$key; - return get_post_meta($product_id, $key, $single); -} - -/** - * update_product_meta function. - * - * @access public - * @param int $product_id - * @param string $key - * @param mixed Metadata value. Must be serializable if non-scalar. - * @param string Optional. Previous value to check before removing. - * Defaults to empty. (default: '') - * @return int|bool Meta ID if the key didn't exist, true on successful update, - * false on failure. - */ -function update_product_meta($product_id, $key, $value, $prev_value = '') { - $key = WPSC_META_PREFIX.$key; - return update_post_meta($product_id, $key, $value, $prev_value); -} - - -/** - * product meta functions end here - */ - -class wpsc_custom_meta { - // Custom meta values - var $custom_meta; - var $custom_meta_count = 0; - var $current_custom_meta = -1; - var $custom_meta_values; - - function __construct( $post_id ) { - - $cleaned_metas = array(); - - if ( ! empty( $post_id ) ) { - $meta_values = get_post_meta( $post_id ); - - foreach ( $meta_values as $key => $values ) { - if ( ! is_protected_meta( $key, 'wpsc-product' ) ) { - if ( is_array( $values ) ) { - foreach ( $values as $value ) { - $cleaned_metas[] = array( 'meta_key' => $key, 'meta_value' => $value ); - } - } - } - } - } - - $this->custom_meta = $cleaned_metas; - $this->custom_meta_count = count( $this->custom_meta ); - } - - function have_custom_meta() { - if (($this->current_custom_meta + 1) < $this->custom_meta_count) { - return true; - } else if ($this->current_custom_meta + 1 == $this->custom_meta_count && $this->custom_meta_count > 0) { - $this->rewind_custom_meta(); - } - return false; - } - - /* - * Custom Meta Loop Code Starts here - */ - function next_custom_meta() { - $this->current_custom_meta++; - $this->custom_meta_values = $this->custom_meta[$this->current_custom_meta]; - return $this->custom_meta_values; - } - - - function the_custom_meta() { - $this->custom_meta_values = $this->next_custom_meta(); - return $this->custom_meta_values; - } - - function rewind_custom_meta() { - if ($this->custom_meta_count > 0) { - $this->custom_meta_values = $this->custom_meta[0]; - } - } -} \ No newline at end of file From 79f4b33a8bf6019a6984a7db63ef0e160567a81f Mon Sep 17 00:00:00 2001 From: andy-1977 <61007039+andy-1977@users.noreply.github.com> Date: Thu, 18 Feb 2021 13:33:28 +0000 Subject: [PATCH 09/17] Delete latest_product_widget.php --- .../widgets/latest_product_widget.php | 167 ------------------ 1 file changed, 167 deletions(-) delete mode 100755 wpsc-components/theme-engine-v1/widgets/latest_product_widget.php diff --git a/wpsc-components/theme-engine-v1/widgets/latest_product_widget.php b/wpsc-components/theme-engine-v1/widgets/latest_product_widget.php deleted file mode 100755 index 87b739f5d5..0000000000 --- a/wpsc-components/theme-engine-v1/widgets/latest_product_widget.php +++ /dev/null @@ -1,167 +0,0 @@ - 'widget_wpsc_latest_products','description' => __( 'Latest Products Widget', 'wp-e-commerce' ) ); - parent::__construct( 'wpsc_latest_products', __( '(WPEC) Latest Products', 'wp-e-commerce' ), $widget_ops ); - } - - /** - * Widget Output - * - * @param $args (array) - * @param $instance (array) Widget values. - */ - function widget( $args, $instance ) { - - global $wpdb, $table_prefix; - - extract( $args ); - - $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Latest Products', 'wp-e-commerce' ) : $instance['title'] ); - - echo $before_widget; - - if ( $title ) - echo $before_title . $title . $after_title; - wpsc_latest_product( $args, $instance ); - echo $after_widget; - } - - /** - * Update Widget - * - * @param $new_instance (array) New widget values. - * @param $old_instance (array) Old widget values. - * - * @return (array) New values. - */ - function update( $new_instance, $old_instance ) { - - $instance = $old_instance; - $instance['title'] = strip_tags( $new_instance['title'] ); - $instance['number'] = (int)$new_instance['number']; - $instance['image'] = (bool)$new_instance['image']; - $instance['height'] = (int)$new_instance['height']; - $instance['width'] = (int)$new_instance['width']; - - return $instance; - - } - - /** - * Widget Options Form - * - * @param $instance (array) Widget values. - */ - function form( $instance ) { - - global $wpdb; - - // Defaults - $instance = wp_parse_args( (array)$instance, array( - 'title' => '', - 'number' => 5, - 'width' => 45, - 'height' => 45, - 'image' => false, - ) ); - - // Values - $title = esc_attr( $instance['title'] ); - $number = (int)$instance['number']; - $image = (bool)$instance['image']; - $width = (int) $instance['width']; - $height = (int) $instance['height']; ?> - -

- - -

- -

- - -

- -

- onclick="jQuery('.wpsc_latest_image').toggle()"> - -

- - - 5 ) ); - $options = get_option( 'wpsc-widget_latest_products' ); - $number = isset($instance['number']) ? (int)$instance['number'] : 5; - $image = isset($instance['image']) ? (bool)$instance['image'] : FALSE; - - if ( isset($instance['width'] ) ) - $width = $instance['width']; - - if ( isset( $instance['height'] ) ) - $height = $instance['height']; - - $latest_products = get_posts( array( - 'post_type' => 'wpsc-product', - 'numberposts' => $number, - 'orderby' => 'post_date', - 'post_parent' => 0, - 'post_status' => 'publish', - 'order' => 'DESC' - ) ); - $output = ''; - - if ( count( $latest_products ) > 0 ) { - $output .= '"; - } - echo $output; - } -?> From 5a02103f876470aab9b716f1bdca03b6314bd399 Mon Sep 17 00:00:00 2001 From: andy-1977 <61007039+andy-1977@users.noreply.github.com> Date: Thu, 18 Feb 2021 13:33:57 +0000 Subject: [PATCH 10/17] Delete wpsc-deprecated.php --- wpsc-core/wpsc-deprecated.php | 2407 --------------------------------- 1 file changed, 2407 deletions(-) delete mode 100644 wpsc-core/wpsc-deprecated.php diff --git a/wpsc-core/wpsc-deprecated.php b/wpsc-core/wpsc-deprecated.php deleted file mode 100644 index f64cf715c6..0000000000 --- a/wpsc-core/wpsc-deprecated.php +++ /dev/null @@ -1,2407 +0,0 @@ - tags have been ommitted. Padding and margins should be applied via css. - * 3. Each product is enclosed in a
with a 'wpec-latest-product' class. - * 4. The product list is enclosed in a
with a 'wpec-latest-products' class. - * 5. Function now expects two arrays as per the standard Widget API. - */ -function nzshpcrt_latest_product( $args = null, $instance ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_latest_product'); - echo wpsc_latest_product( $args, $instance ); -} - -/** - * nzshpcrt_currency_display function. - * Obsolete, preserved for backwards compatibility - * - * @access public - * @param mixed $price_in - * @param mixed $tax_status - * @param bool $nohtml deprecated - * @param bool $id. deprecated - * @param bool $no_dollar_sign. (default: false) - * @return void - */ -function nzshpcrt_currency_display($price_in, $tax_status, $nohtml = false, $id = false, $no_dollar_sign = false) { - _wpsc_deprecated_function( __FUNCTION__, '3.8' ); - - $output = wpsc_currency_display($price_in, array( - 'display_currency_symbol' => !(bool)$no_dollar_sign, - 'display_as_html' => ! (bool)$nohtml, - 'display_decimal_point' => true, - 'display_currency_code' => false - )); - return $output; -} - -/** - * This should be deprecated using _wpsc_deprecated_function() however the - * constants are still being used in admin-legacy.js, which is still enqueued - * by default in wp-admin. - * - * @deprecated - */ -function wpsc_include_language_constants(){ - // _wpsc_deprecated_function( __FUNCTION__, '3.8' ); - - if(!defined('TXT_WPSC_ABOUT_THIS_PAGE')) - include_once(WPSC_FILE_PATH.'/wpsc-languages/EN_en.php'); -} -add_action('init','wpsc_include_language_constants'); - -if(!function_exists('wpsc_has_noca_message')){ - function wpsc_has_noca_message(){ - _wpsc_deprecated_function( __FUNCTION__, '3.8' ); - if(isset($_SESSION['nocamsg']) && isset($_GET['noca']) && $_GET['noca'] == 'confirm') - return true; - else - return false; - } -} - -if(!function_exists('wpsc_is_noca_gateway')){ - function wpsc_is_noca_gateway(){ - _wpsc_deprecated_function( __FUNCTION__, '3.8' ); - if(count($wpsc_gateway->wpsc_gateways) == 1 && $wpsc_gateway->wpsc_gateways[0]['name'] == 'Noca') - return true; - else - return false; - } -} - -/** - * wpsc current_page - * @return (int) The current page number - */ -function wpsc_current_page() { - _wpsc_deprecated_function( __FUNCTION__, '3.8' ); - - global $wpsc_query; - - $current_page = 1; - - if ( $wpsc_query->query_vars['page'] > 1) { - $current_page = $wpsc_query->query_vars['page']; - } - - return $current_page; - -} - -/** - * wpsc showing products - * Displays the number of page showing in the form "10 to 20". - * If only on page is being display it will return the total amount of products showing. - * @return (string) Number of products showing - */ -function wpsc_showing_products() { - _wpsc_deprecated_function( __FUNCTION__, '3.8' ); - - global $wpsc_query; - - // If we are using pages... - if ( ( get_option( 'use_pagination' ) == 1 ) ) { - $products_per_page = $wpsc_query->query_vars['number_per_page']; - if ( $wpsc_query->query_vars['page'] > 0 ) { - $startnum = ( $wpsc_query->query_vars['page'] - 1 ) * $products_per_page; - } else { - $startnum = 0; - } - return ( $startnum + 1 ) . ' to ' . ( $startnum + wpsc_product_count() ); - } - - return wpsc_total_product_count(); - -} - -/** - * wpsc showing products page - * Displays the number of page showing in the form "5 of 10". - * @return (string) Number of pages showing. - */ -function wpsc_showing_products_page() { - _wpsc_deprecated_function( __FUNCTION__, '3.8' ); - - global $wpsc_query; - - $output = $wpsc_query->page_count; - $current_page = wpsc_current_page(); - - return $current_page . ' of ' . $output; - -} - - -/** - * is wpsc profile page - * Checks if the current account page tab is Edit Profile. - * @deprecated since 3.8.10 - * @return (boolean) true if current tab ID is edit_profile. - */ -function is_wpsc_profile_page() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.10' ); - return !empty($_REQUEST['tab']) && ( $_REQUEST['tab'] == 'edit_profile' ); -} - -/** - * is wpsc profile page - * Checks if the current account page tab is Downloads. - * @deprecated since 3.8.10 - * @return (boolean) true if current tab ID is downloads. - */ -function is_wpsc_downloads_page() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.10' ); - return !empty($_REQUEST['tab']) && ( $_REQUEST['tab'] == 'downloads' ); -} - - -/** - * wpsc user details - * Displays the Purchase History account page section. - * @deprecated since 3.8.10 - * @return (string) The Purchase History page template. - */ -function wpsc_user_details() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.10' ); - return wpsc_user_purchases(); -} - - -/** - * wpsc product search url - * Add product_search parameter if required. - * @param $url (string) URL. - * @return (string) URL. - */ -function wpsc_product_search_url( $url ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8' ); - if ( isset( $_GET['product_search'] ) ) { - if ( strrpos( $url, '?') ) { - $url .= '&product_search=' . $_GET['product_search']; - } else { - $url .= '?product_search=' . $_GET['product_search']; - } - } - - return $url; - -} - -/** - * wpsc adjacent products url - * URL for the next or previous page of products on a category or group page. - * @param $n (int) Page number. - * @return (string) URL for the adjacent products page link. - */ -function wpsc_adjacent_products_url( $n ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination'); - return false; - -} - -/** - * wpsc next products link - * Links to the next page of products on a category or group page. - * @param $text (string) Link text. - * @param $show_disabled (bool) Show unlinked text if last page. - * @return (string) Next page link or text. - */ -function wpsc_next_products_link( $text = 'Next', $show_disabled = false ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination'); - return false; -} - -/** - * wpsc previous products link - * Links to the previous page of products on a category or group page. - * @param $text (string) Link text. - * @param $show_disabled (bool) Show unlinked text if first page. - * @return (string) Previous page link or text. - */ -function wpsc_previous_products_link( $text = 'Previous', $show_disabled = false ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination'); - return false; -} - -/** - * wpsc first products link - * Links to the first page of products on a category or group page. - * @param $text (string) Link text. - * @param $show_disabled (bool) Show unlinked text if last page. - * @return (string) First page link or text. - */ -function wpsc_first_products_link( $text = 'First', $show_disabled = false ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination'); - return false; -} - -/** - * wpsc last products link - * Links to the last page of products on a category or group page. - * @param $text (string) Link text. - * @param $show_disabled (bool) Show unlinked text if first page. - * @return (string) Last page link or text. - */ -function wpsc_last_products_link( $text = 'Last', $show_disabled = false ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination'); - return false; - -} - -/** - * Saves the variation set data - * @param nothing - * @return nothing - */ -function wpsc_save_variation_set() { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); - return false; -} - -/** - * wpsc have pages function - * @return boolean - true while we have pages to loop through - */ -function wpsc_have_pages() { - _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination'); - return false; -} - -/** - * wpsc the page function - * @return nothing - iterate through the pages - */ -function wpsc_the_page() { - _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination'); - return false; -} - -/** - * wpsc page number function - * @return integer - the page number - */ -function wpsc_page_number() { - _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination'); - return false; -} - -function wpsc_ordersummary() { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); - return false; -} - -function display_ecomm_rss_feed() { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); - return false; -} - -function display_ecomm_admin_menu() { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); - return false; -} - -// displays error messages if the category setup is odd in some way -// needs to be in a function because there are at least three places where this code must be used. -function wpsc_odd_category_setup() { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); - return false; -} - -function wpsc_product_image_html( $image_name, $product_id ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); - return false; -} - -function wpsc_delete_currency_layer() { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); - return false; -} - -function wpsc_akst_send_mail() { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); - return false; -} - -function wpsc_akst_hide_pop() { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); - return false; -} - -function wpsc_akst_page() { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); - return false; -} - -function wpsc_akst_share_link($action = 'print') { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); - if($action == 'print') - echo '
'; - else - return '
'; - return false; -} - -function wpsc_akst_share_form() { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); - return false; -} - -function wpsc_has_shipping_form() { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); - return false; -} - -/** - * wpsc_is_admin function. - * - * @access public - * @return void - * General use function for checking if user is on WPSC admin pages - */ - -function wpsc_is_admin() { - _wpsc_deprecated_function( __FUNCTION__, '3.8'); - global $pagenow; - - $current_screen = get_current_screen(); - - if( 'post.php' == $pagenow && 'wpsc-product' == $current_screen->post_type ) return true; - - return false; - -} - -/** - * used in legacy theme templates - * see http://plugins.svn.wordpress.org/wp-e-commerce/tags/3.7.8/themes/default/category_widget.php - * - * @return void - */ -function wpsc_print_product_list() { - _wpsc_deprecated_function( __FUNCTION__, '3.8' ); -} - -/** - * count total products on a page - * see http://plugins.svn.wordpress.org/wp-e-commerce/tags/3.7.8/themes/iShop/products_page.php - * - * @return int - */ -function wpsc_total_product_count() { - _wpsc_deprecated_function( __FUNCTION__, '3.8' ); - return wpsc_product_count(); -} - -/** - * WPSC_Query() is deprecated in favor of WP_Query() - * Note that although we fall back to WP_Query() when WPSC_Query() is used, - * the results might not be what you expect. - * - */ -class WPSC_Query extends WP_Query { - public function __construct( $query = '' ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8', 'WP_Query()' ); - $query = wp_parse_args( $query ); - $query['post_type'] = 'wpsc-product'; - parent::WP_Query( $query ); - } -} - -function wpec_get_the_post_id_by_shortcode( $shortcode ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.9', 'wpsc_get_the_post_id_by_shortcode' ); - return wpsc_get_the_post_id_by_shortcode( $shortcode ); -} - -/** - * wpsc_update_permalinks update the product pages permalinks when WordPress permalinks are changed - * - * @public - * - * @deprecated Use _wpsc_action_permalink_structure_changed() instead. - * @3.8 - * @returns nothing - */ -function wpsc_update_permalinks( $return = '' ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.9', '_wpsc_action_permalink_structure_changed' ); - _wpsc_action_permalink_structure_changed(); -} - -/** - * @deprecated Use _wpsc_display_permalink_refresh_notice() instead; - */ -function wpsc_check_permalink_notice() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.9', '_wpsc_display_permalink_refresh_notice' ); - _wpsc_display_permalink_refresh_notice(); -} - -/** - * @deprecated since 3.8.8. Not used in core any more. - */ -function wpsc_display_tracking_id(){ - _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - $value = wpsc_trackingid_value(); - if(!empty($value)) - return $value; - else - return __('Add New','wp-e-commerce'); -} - -/** - * @deprecated since 3.8.8. Not used in core any more. - */ -function wpsc_the_purch_item_price() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - if ( $purchlogs->purchitem->processed > 1 && $purchlogs->purchitem->processed != 6 ) { - $purchlogs->totalAmount += $purchlogs->purchitem->totalprice; - } - return $purchlogs->purchitem->totalprice; -} - -/** - * @deprecated since 3.8.8. Not used in core any more. - */ -function wpsc_the_purch_item_date() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - return date( 'M d Y,g:i a', $purchlogs->purchitem->date ); -} - -/** - * @deprecated since 3.8.8. Not used in core any more. - */ -function wpsc_the_purch_item_name() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - if ( wpsc_purchlogs_has_customfields( wpsc_the_purch_item_id() ) ) { - return $purchlogs->the_purch_item_name() . '' . esc_attr__( 'exclamation icon', 'wp-e-commerce' ) . ''; - } else { - return $purchlogs->the_purch_item_name(); - } -} - -/** - * @deprecated since 3.8.8. Not used in core any more. - */ -function wpsc_the_purch_item_id() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - return $purchlogs->purchitem->id; -} - -/** - * @deprecated since 3.8.8. Not used in core any more. - */ -function wpsc_the_purch_item_details() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - return $purchlogs->the_purch_item_details(); -} - -//status loop functions -/** - * status loop functions - * @deprecated since 3.8.8. Not used in core any more. - */ -function wpsc_have_purch_items_statuses() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - return $purchlogs->have_purch_status(); -} - -/** - * @deprecated since 3.8.8. Not used in core any more. - */ -function wpsc_the_purch_status() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - return $purchlogs->the_purch_status(); -} - -/** - * @deprecated since 3.8.8. Not used in core any more. - */ -function wpsc_purchlogs_is_google_checkout() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - if ( $purchlogs->purchitem->gateway == 'google' ) { - return true; - } else { - return false; - } -} - -/** - * @deprecated since 3.8.8. Not used in core any more. - */ -function wpsc_the_purch_total() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - return $purchlogs->totalAmount; -} - -/** - * @deprecated since 3.8.8. Not used in core any more. - */ -function wpsc_the_purch_item() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - if ( isset( $_SESSION['newlogs'] ) ) { - $purchlogs->allpurchaselogs = $_SESSION['newlogs']; - $purchlogs->purch_item_count = count( $_SESSION['newlogs'] ); - } - return $purchlogs->the_purch_item(); -} - -/** - * @deprecated since 3.8.8. Not used in core any more. - */ -function wpsc_the_purch_item_statuses() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - return $purchlogs->the_purch_item_statuses(); -} - -/** - * @deprecated since 3.8.8. Not used in core any more. - */ -function wpsc_the_purch_item_status() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - return $purchlogs->the_purch_item_status(); -} - -/** - * @deprecated since 3.8.8. Not used in core any more. - */ -function wpsc_the_purch_status_id() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - return $purchlogs->purchstatus['order']; -} - -/** - * @deprecated since 3.8.8. Not used in core any more. - */ -function wpsc_purchlog_filter_by() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - wpsc_change_purchlog_view( $_POST['view_purchlogs_by'], $_POST['view_purchlogs_by_status'] ); -} - -/** - * @deprecated since 3.8.8. Not used in core any more. - */ -function wpsc_the_purch_status_name() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - if ( isset( $purchlogs->purchstatus['label'] ) ) { - return $purchlogs->purchstatus['label']; - } -} - -/** - * @deprecated since 3.8.8. Not used in core any more. - */ -function wpsc_purchlogs_getfirstdates() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - $dates = $purchlogs->getdates(); - $fDate = ''; - foreach ( $dates as $date ) { - $is_selected = ''; - $cleanDate = date( 'M Y', $date['start'] ); - $value = $date["start"] . "_" . $date["end"]; - if ( $value == $_GET['view_purchlogs_by'] ) { - $is_selected = 'selected="selected"'; - } - $fDate .= ""; - } - return $fDate; -} - -/** - * @deprecated since 3.8.8. Not used in core any more. - */ -function wpsc_change_purchlog_view( $viewby, $status='' ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - if ( $viewby == 'all' ) { - $dates = $purchlogs->getdates(); - $purchaselogs = $purchlogs->get_purchlogs( $dates, $status ); - $_SESSION['newlogs'] = $purchaselogs; - $purchlogs->allpurchaselogs = $purchaselogs; - } elseif ( $viewby == '3mnths' ) { - $dates = $purchlogs->getdates(); - $dates = array_slice( $dates, 0, 3 ); - $purchlogs->current_start_timestamp = $dates[count($dates)-1]['start']; - $purchlogs->current_end_timestamp = $dates[0]['end']; - $newlogs = $purchlogs->get_purchlogs( $dates, $status ); - $_SESSION['newlogs'] = $newlogs; - $purchlogs->allpurchaselogs = $newlogs; - } else { - - $dates = explode( '_', $viewby ); - $date[0]['start'] = $dates[0]; - $date[0]['end'] = $dates[1]; - $purchlogs->current_start_timestamp = $dates[0]; - $purchlogs->current_end_timestamp = $dates[1]; - $newlogs = $purchlogs->get_purchlogs( $date, $status ); - $_SESSION['newlogs'] = $newlogs; - $purchlogs->allpurchaselogs = $newlogs; - } -} - -/** - * @deprecated since 3.8.8. Not used in core any more. - */ -function wpsc_search_purchlog_view( $search ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogs; - $newlogs = $purchlogs->search_purchlog_view( $search ); - $purchlogs->getDates(); - $purchlogs->purch_item_count = count( $newlogs ); - $purchlogs->allpurchaselogs = $newlogs; -} - -/** - * @deprecated since 3.8.8. Not used in core any more. - */ -function wpsc_purchlog_is_checked_status() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); - global $purchlogitem, $purchlogs; - - if ( $purchlogs->purchstatus['order'] == $purchlogitem->extrainfo->processed ) { - return 'selected="selected"'; - } else { - return ''; - } -} - -/** - * @deprecated since 3.8.9. Use _wpsc_country_dropdown_options instead. - * @param string $selected_country ISO code of selected country - * @return string output - */ -function country_list( $selected_country = null ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.9', '_wpsc_country_dropdown_options' ); - return _wpsc_country_dropdown_options( array( 'selected' => $selected_country ) ); -} - -/** - * @deprecated since 3.8.9. Use wpsc_get_the_product_tags() instead. - * @param integer $id Product ID - * @return array Product tags - */ -function get_the_product_tags( $id = 0 ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.9', 'wpsc_get_the_product_tags' ); - return wpsc_get_the_product_tags( $id ); -} - -/** - * wpsc_product_rows function, copies the functionality of the wordpress code for displaying posts and pages, but is for products - * - * @deprecated since 3.8.9 - */ -function wpsc_admin_product_listing( $parent_product = null, $args = array() ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.9' ); - global $wp_query; - - if ( empty( $args ) ) - $args = $wp_query->query; - - add_filter( 'the_title','esc_html' ); - - $args = array_merge( $args, array( 'posts_per_page' => '-1' ) ); - - $GLOBALS['wpsc_products'] = get_posts( $args ); - - if ( ! $GLOBALS['wpsc_products'] ) : - - ?> - - - - - - - static $rowclass, $object_terms_cache = array(); - - // store terms associated with variants inside a cache array. This only requires 1 DB query. - if ( empty( $object_terms_cache ) ) { - $ids = wp_list_pluck( $wpsc_products, 'ID' ); - $object_terms = wp_get_object_terms( $ids, 'wpsc-variation', array( 'fields' => 'all_with_object_id' ) ); - foreach ( $object_terms as $term ) { - if ( ! array_key_exists( $term->object_id, $object_terms_cache ) ) - $object_terms_cache[$term->object_id] = array(); - - $object_terms_cache[$term->object_id][$term->parent] = $term->name; - } - } - - $global_product = $product; - setup_postdata($product); - $product_post_type_object = get_post_type_object('wpsc-product'); - $current_user_can_edit_this_product = current_user_can( $product_post_type_object->cap->edit_post, $product->ID ); - - $rowclass = 'alternate' == $rowclass ? '' : 'alternate'; - $post_owner = ( $current_user->ID == $product->post_author ? 'self' : 'other' ); - $edit_link = get_edit_post_link( $product->ID ); - - if ( isset( $object_terms_cache[$product->ID] ) ) { - ksort( $object_terms_cache[$product->ID] ); - $title = implode( ', ', $object_terms_cache[$product->ID] ); - } else { - $title = get_the_title( $product->ID ); - } - - if ( empty( $title ) ) - $title = __( '(no title)', 'wp-e-commerce' ); - - ?> - - post_status ); ?> iedit ' valign="top"> - '', 'title' => __('Name', 'wp-e-commerce') , 'weight' => __('Weight', 'wp-e-commerce'), 'stock' => __('Stock', 'wp-e-commerce'), 'price' => __('Price', 'wp-e-commerce'), 'sale_price' => __('Sale Price', 'wp-e-commerce'), 'SKU' => __('SKU', 'wp-e-commerce'), 'hidden_alerts' => ''); - - foreach ( $posts_columns as $column_name=>$column_display_name ) { - $attributes = "class=\"$column_name column-$column_name\""; - - switch ($column_name) { - - case 'date': /* !date case */ - if ( '0000-00-00 00:00:00' == $product->post_date && 'date' == $column_name ) { - $t_time = $h_time = __( 'Unpublished', 'wp-e-commerce' ); - $time_diff = 0; - } else { - $t_time = get_the_time( __( 'Y/m/d g:i:s A', 'wp-e-commerce' ) ); - $m_time = $product->post_date; - $time = get_post_time('G', true, $post); - - $time_diff = time() - $time; - - if ( $time_diff > 0 && $time_diff < 24*60*60 ) - $h_time = sprintf( __( '%s ago', 'wp-e-commerce' ), human_time_diff( $time ) ); - else - $h_time = mysql2date(__( 'Y/m/d', 'wp-e-commerce' ), $m_time); - } - - echo ''; - if ( 'excerpt' == $mode ) - echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode); - else - echo '' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . ''; - echo '
'; - if ( 'publish' == $product->post_status ) { - _e( 'Published', 'wp-e-commerce' ); - } elseif ( 'future' == $product->post_status ) { - if ( $time_diff > 0 ) - echo '' . __( 'Missed schedule', 'wp-e-commerce' ) . ''; - else - _e( 'Scheduled', 'wp-e-commerce' ); - } else { - _e( 'Last Modified', 'wp-e-commerce' ); - } - echo ''; - break; - - case 'title': /* !title case */ - $attributes = 'class="post-title column-title"'; - - $edit_link = wp_nonce_url( $edit_link, 'edit-product_'.$product->ID ); - ?> - > - - post_status != 'trash' ) { ?> - - - - - - - <?php echo $product_alert[' title='' class='product-alert-image' src='/product-alert.jpg' alt='' /> - - - ID)) - $has_var = 'wpsc_has_variation'; - $actions = array(); - if ( $current_user_can_edit_this_product && 'trash' != $product->post_status ) { - $actions['edit'] = ''. __( 'Edit', 'wp-e-commerce' ) . ''; - //commenting this out for now as we are trying new variation ui quick edit boxes are open by default so we dont need this link. - //$actions['quick_edit'] = "".__('Quick Edit', 'wp-e-commerce').""; - } - - $actions = apply_filters('post_row_actions', $actions, $product); - $action_count = count($actions); - $i = 0; - echo '
'; - - foreach ( $actions as $action => $link ) { - ++$i; - ( $i == $action_count ) ? $sep = '' : $sep = ' | '; - echo "$link$sep"; - } - - echo '
'; - ?> - - - - 'attachment', - 'numberposts' => 1, - 'post_status' => null, - 'post_parent' => $product->ID, - 'orderby' => 'menu_order', - 'order' => 'ASC' - ); - - if(isset($product->ID) && has_post_thumbnail($product->ID)){ - echo get_the_post_thumbnail($product->ID, 'admin-product-thumbnails'); - } else { - $image_url = WPSC_CORE_IMAGES_URL . "/no-image-uploaded.gif"; - ?> - ' src='' alt='' width='38' height='38' /> - - - ID, 'price', true); - ?> - > - - - - - ID, ''); - foreach($product_data['meta'] as $meta_name => $meta_value) { - $product_data['meta'][$meta_name] = maybe_unserialize(array_pop($meta_value)); - } - $product_data['transformed'] = array(); - if(!isset($product_data['meta']['_wpsc_product_metadata']['weight'])) $product_data['meta']['_wpsc_product_metadata']['weight'] = ""; - if(!isset($product_data['meta']['_wpsc_product_metadata']['weight_unit'])) $product_data['meta']['_wpsc_product_metadata']['weight_unit'] = ""; - - $product_data['transformed']['weight'] = wpsc_convert_weight($product_data['meta']['_wpsc_product_metadata']['weight'], "pound", $product_data['meta']['_wpsc_product_metadata']['weight_unit'], false); - $weight = $product_data['transformed']['weight']; - if($weight == ''){ - $weight = '0'; - } - ?> - > - - - - - ID, '_wpsc_stock', true); - ?> - > - - - - - - >ID); - if ( !empty( $categories ) ) { - $out = array(); - foreach ( $categories as $c ) - $out[] = " " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . ""; - echo join( ', ', $out ); - } else { - esc_html_e( 'Uncategorized', 'wp-e-commerce' ); - } - ?> - - >ID); - if ( !empty( $tags ) ) { - $out = array(); - foreach ( $tags as $c ) - $out[] = " " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . ""; - echo join( ', ', $out ); - } else { - esc_html_e( 'No Tags', 'wp-e-commerce' ); - } - ?> - ID, '_wpsc_sku', true); - ?> - > - - - -

- - ID, '_wpsc_special_price', true); - ?> - > - - - - - >
- '; - comments_number("" . /* translators: comment count link */ _x( '0', 'comment count', 'wp-e-commerce' ) . '', "" . /* translators: comment count link */ _x('1', 'comment count', 'wp-e-commerce') . '', "" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count', 'wp-e-commerce') . ''); - if ( $pending_comments ) - echo ''; - ?> -
- - > - - - - " . esc_html__( 'Edit', 'wp-e-commerce' ) . ""; } ?> - - ID) . "' class='delete'>" . __( 'Delete', 'wp-e-commerce' ) . ""; } ?> - - ID ); ?> - - >ID ); ?> - - -post_type && 'trash' == $post->post_status && !in_array('trash', $post_status)) - $post_status[] = 'Trash'; - - return $post_status; -} - -function wpsc_product_label_forms() { - _wpsc_deprecated_function( __FUNCTION__, '3.8' ); - return false; -} - -function wpsc_convert_weights($weight, $unit) { - _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_convert_weight' ); - if (is_array($weight)) { - $weight = $weight['weight']; - } - return wpsc_convert_weight( $weight, $unit, 'gram', true ); -} - -/** - * wpsc in the loop function, - * @return boolean - true if we are in the loop - */ -function wpsc_in_the_loop() { - _wpsc_deprecated_function( __FUNCTION__, '3.8' ); - global $wpsc_query; - return $wpsc_query->in_the_loop; -} - -/** - * wpsc rewind products function, rewinds back to the first product - * @return nothing - */ -function wpsc_rewind_products() { - _wpsc_deprecated_function( __FUNCTION__, '3.8' ); - global $wpsc_query; - return $wpsc_query->rewind_posts(); -} - -/** - * wpsc product has file function - * @return boolean - true if the product has a file - */ -function wpsc_product_has_file() { - _wpsc_deprecated_function( __FUNCTION__, '3.8' ); - global $wpsc_query, $wpdb; - if ( is_numeric( $wpsc_query->product['file'] ) && ($wpsc_query->product['file'] > 0) ) - return true; - - return false; -} - -/** - * wpsc currency sign function - * @return string - the selected currency sign for the store - */ -function wpsc_currency_sign() { - _wpsc_deprecated_function( __FUNCTION__, '3.8' ); - global $wpdb; - $currency_sign_location = get_option( 'currency_sign_location' ); - $currency_type = get_option( 'currency_type' ); - $currency_symbol = $wpdb->get_var( $wpdb->prepare( "SELECT `symbol_html` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id` = %d LIMIT 1", $currency_type ) ); - - return $currency_symbol; -} - -/** - * wpsc page is selected function - * @return boolean - true if the page is selected - */ -function wpsc_page_is_selected() { - _wpsc_deprecated_function( __FUNCTION__, '3.8' ); - // determine if we are on this page - global $wpsc_query; - return $wpsc_query->page['selected']; -} - -/** - * wpsc page URL function - * @return string - the page URL - */ -function wpsc_page_url() { - _wpsc_deprecated_function( __FUNCTION__, '3.8' ); - // generate the page URL - global $wpsc_query; - return $wpsc_query->page['url']; -} - -function shipwire_build_xml( $log_id ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.9', 'WPSC_Shipwire' ); - return WPSC_Shipwire::get_order_xml( $log_id ); -} - -function shipwire_built_sync_xml() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.9', 'WPSC_Shipwire' ); - return WPSC_Shipwire::get_inventory_xml(); -} - -function shipwire_built_tracking_xml() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.9', 'WPSC_Shipwire' ); - return WPSC_Shipwire::get_tracking_xml(); -} - -function shipwire_send_sync_request( $xml ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.9', 'WPSC_Shipwire' ); - return WPSC_Shipwire::send_inventory_request( $xml ); -} - -function shipwire_sent_request( $xml ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.9', 'WPSC_Shipwire' ); - return WPSC_Shipwire::send_order_request( $xml ); -} - -function shipwire_send_tracking_request( $xml ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.9', 'WPSC_Shipwire' ); - return WPSC_Shipwire::send_tracking_request( $xml ); -} - -function wpsc_rage_where( $where ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.8', 'wpsc_range_where()' ); - return wpsc_range_where( $where ); -} - -/** - * WPSC Product Variation Price Available - * Gets the formatted lowest price of a product's available variations. - * - * @param $product_id (int) Product ID - * @param $from_text (string) From text with price placeholder eg. 'from %s' - * @param $only_normal_price (bool) Don't show sale price - * @return (string) Number formatted price - * - * @uses wpsc_product_variation_price_from() - */ -function wpsc_product_variation_price_available( $product_id, $from_text = false, $only_normal_price = false ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.10', 'wpsc_product_variation_price_from()' ); - $args = array( - 'from_text' => $from_text, - 'only_normal_price' => $only_normal_price, - 'only_in_stock' => true - ); - return wpsc_product_variation_price_from( $product_id, $args ); -} - -/** - * Deprecated function - * - * @deprecated 3.8.9 - */ -function wpsc_post_title_seo( $title ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.9' ); - global $wpdb, $page_id, $wp_query; - $new_title = wpsc_obtain_the_title(); - if ( $new_title != '' ) { - $title = $new_title; - } - return esc_html( $title ); -} - -function wpsc_product_image_forms() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.13' ); - - global $post; - - edit_multiple_image_gallery( $post ); - -?> - -

>

-ID > 0 ) { - if ( has_post_thumbnail( $post->ID ) ) - echo get_the_post_thumbnail( $post->ID, 'admin-product-thumbnails' ); - - $args = array( - 'post_type' => 'attachment', - 'numberposts' => -1, - 'post_status' => null, - 'post_parent' => $post->ID, - 'orderby' => 'menu_order', - 'order' => 'ASC' - ); - - $attached_images = (array)get_posts( $args ); - - if ( count( $attached_images ) > 0 ) { - foreach ( $attached_images as $images ) { - $attached_image = wp_get_attachment_image( $images->ID, 'admin-product-thumbnails' ); - echo $attached_image. ' '; - } - } - - } -} - -function wpsc_media_upload_tab_gallery( $tabs ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.13' ); - - unset( $tabs['gallery'] ); - $tabs['gallery'] = __( 'Product Image Gallery', 'wp-e-commerce' ); - - return $tabs; -} - -function wpsc_media_upload_url( $form_action_url ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.13' ); - - $form_action_url = esc_url( add_query_arg( array( 'parent_page'=>'wpsc-edit-products' ) ) ); - - return $form_action_url; - -} - -function wpsc_gallery_css_mods() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.13' ); - - print ''; - print ' - '; -} - -function wpsc_filter_delete_text( $translation, $text, $domain ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.13' ); - - if ( 'Delete' == $text && isset( $_REQUEST['post_id'] ) && isset( $_REQUEST['parent_page'] ) ) { - $translations = &get_translations_for_domain( $domain ); - return $translations->translate( 'Trash' ) ; - } - return $translation; -} - -/* - * This filter translates string before it is displayed - * specifically for the words 'Use as featured image' with 'Use as Product Thumbnail' when the user is selecting a Product Thumbnail - * using media gallery. - * - * @todo As this feature is entirely cosmetic and breaks with WP_DEBUG on in WP 3.5+, we've removed the filter for it. Will revisit the functionality in 3.9 when we look at new media workflows. - * @param $translation The current translation - * @param $text The text being translated - * @param $domain The domain for the translation - * @return string The translated / filtered text. - */ -function wpsc_filter_feature_image_text( $translation, $text, $domain ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.13' ); - if ( 'Use as featured image' == $text && isset( $_REQUEST['post_id'] ) ) { - $post = get_post( $_REQUEST['post_id'] ); - if ( $post->post_type != 'wpsc-product' ) return $translation; - $translations = &get_translations_for_domain( $domain ); - return $translations->translate( 'Use as Product Thumbnail', 'wp-e-commerce' ); - //this will never happen, this is here only for gettexr to pick up the translation - return __( 'Use as Product Thumbnail', 'wp-e-commerce' ); - } - - return $translation; -} - -function wpsc_display_invoice() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.13' ); - - if ( ! wpsc_is_store_admin() ) { - return; - } - - $purchase_id = (int)$_REQUEST['purchaselog_id']; - add_action('wpsc_packing_slip', 'wpsc_packing_slip'); - do_action('wpsc_before_packing_slip', $purchase_id); - do_action('wpsc_packing_slip', $purchase_id); - exit(); -} - -function wpsc_packing_slip( $purchase_id ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.13' ); - echo "" . __( 'Packing Slip', 'wp-e-commerce' ) . ""; - global $wpdb; - $purch_sql = $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `id`=%d", $purchase_id ); - $purch_data = $wpdb->get_row( $purch_sql, ARRAY_A ) ; - - $cartsql = $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`=%d", $purchase_id ); - $cart_log = $wpdb->get_results($cartsql,ARRAY_A) ; - $j = 0; - - if($cart_log != null) { - echo "
\n\r"; - echo apply_filters( 'wpsc_packing_slip_header', '

' . esc_html__( 'Packing Slip', 'wp-e-commerce' ) . "

\n\r" ); - echo "". esc_html__( 'Order', 'wp-e-commerce' )." # ".$purchase_id."

\n\r"; - - echo "\n\r"; - - $form_sql = $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_SUBMITTED_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 `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `active` = '1' ORDER BY `checkout_order`" , ARRAY_A ); - - foreach($form_data as $form_field) { - - switch($form_field['type']) { - case 'country': - $region_count_sql = $wpdb->prepare( "SELECT COUNT(`regions`.`id`) FROM `".WPSC_TABLE_REGION_TAX."` AS `regions` INNER JOIN `".WPSC_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 " \n\r"; - - echo " \n\r"; - break; - - case 'delivery_country': - - if(is_numeric($purch_data['shipping_region']) && ($delivery_region_count > 0)) - echo " \n\r"; - - echo " \n\r"; - break; - - case 'heading': - - if($form_field['name'] == "Hidden Fields") - break; - else - echo " \n\r"; - break; - - default: - if ($form_field['name']=="State" && !empty($purch_data['billing_region']) || $form_field['name']=="State" && !empty($purch_data['billing_region'])) - echo ""; - else - echo " \n\r"; - break; - } - - } - } else { - echo " \n\r"; - echo " \n\r"; - echo " \n\r"; - echo " \n\r"; - } - - if ( 2 == get_option( 'payment_method' ) ) { - $gateway_name = ''; - global $nzshpcrt_gateways; - - foreach( $nzshpcrt_gateways as $gateway ) { - if ( $purch_data['gateway'] != 'testmode' ) { - if ( $gateway['internalname'] == $purch_data['gateway'] ) { - $gateway_name = $gateway['name']; - } - } else { - $gateway_name = esc_html__('Manual Payment', 'wp-e-commerce'); - } - } - } - - echo "
".esc_html__('State', 'wp-e-commerce').":".wpsc_get_region($purch_data['billing_region'])."
" . esc_html( $form_field['name'] ) . ":" . esc_html( $rekeyed_input[$form_field['id']]['value'] ) . "
".esc_html__('State', 'wp-e-commerce').":".wpsc_get_region($purch_data['shipping_region'])."
" . esc_html( $form_field['name'] ) . ":" . esc_html( $rekeyed_input[ $form_field['id']]['value'] ) . "
" . esc_html( $form_field['name'] ) . ":
" . esc_html( $form_field['name'] ) . ":". - ( isset( $rekeyed_input[$form_field['id']] ) ? esc_html( $rekeyed_input[$form_field['id']]['value'] ) : '' ) . - "
".esc_html__('Name', 'wp-e-commerce').":".$purch_data['firstname']." ".$purch_data['lastname']."
".esc_html__('Address', 'wp-e-commerce').":".$purch_data['address']."
".esc_html__('Phone', 'wp-e-commerce').":".$purch_data['phone']."
".esc_html__('Email', 'wp-e-commerce').":".$purch_data['email']."
\n\r"; - - - do_action ('wpsc_packing_slip_extra_info',$purchase_id); - - - echo ""; - - echo ""; - echo " "; - - echo " "; - - - echo " "; - - echo " "; - echo ''; - echo ''; - $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 ""; - - - echo " "; - - echo " "; - - - echo " "; - - echo " "; - - - - echo ''; - echo ''; - } - - echo "
".esc_html__('Quantity', 'wp-e-commerce')." ".esc_html__('Name', 'wp-e-commerce')."".esc_html__('Price', 'wp-e-commerce')." ".esc_html__('Shipping', 'wp-e-commerce')." ' . esc_html__('Tax', 'wp-e-commerce') . '
"; - echo $cart_row['quantity']; - echo " "; - echo apply_filters( 'the_title', $cart_row['name'] ); - echo $variation_list; - echo " "; - echo wpsc_currency_display( $price ); - echo " "; - echo wpsc_currency_display($shipping ); - echo " '; - echo wpsc_currency_display( $cart_row['tax_charged'] ); - echo '
"; - echo ''; - if ( floatval( $purch_data['discount_value'] ) ) - echo ''; - - echo ''; - echo ''; - //wpec_taxes - if($purch_data['wpec_taxes_total'] != 0.00) - { - echo ''; - } - echo ''; - echo '
'.esc_html__('Discount', 'wp-e-commerce').'(' . wpsc_currency_display( $purch_data['discount_value'] ) . ')
'.esc_html__('Base Shipping','wp-e-commerce').'' . wpsc_currency_display( $purch_data['base_shipping'] ) . '
'.esc_html__('Total Shipping','wp-e-commerce').'' . wpsc_currency_display( $purch_data['base_shipping'] + $total_shipping ) . '
'.esc_html__('Taxes','wp-e-commerce').'' . wpsc_currency_display( $purch_data['wpec_taxes_total'] ) . '
'.esc_html__('Total Price','wp-e-commerce').'' . wpsc_currency_display( $purch_data['totalprice'] ) . '
'; - - echo "
\n\r"; - } else { - echo "
".esc_html__('This users cart was empty', 'wp-e-commerce'); - } -} - -//other actions are here -if ( isset( $_GET['display_invoice'] ) && ( 'true' == $_GET['display_invoice'] ) ) - add_action( 'admin_init', 'wpsc_display_invoice', 0 ); - -if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( 'wpsc_display_invoice' == $_REQUEST['wpsc_admin_action'] ) ) - add_action( 'admin_init', 'wpsc_display_invoice' ); - - -/** - * Disable SSL validation for Curl. Added/removed on a per need basis, like so: - * - * add_filter('http_api_curl', 'wpsc_curl_ssl'); - * remove_filter('http_api_curl', 'wpsc_curl_ssl'); - * - * @param resource $ch - * @return resource $ch - **/ -function wpsc_curl_ssl( $ch ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.13', "add_filter( 'https_ssl_verify', '__return_false' )" ); - - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); - return $ch; -} - - -/** - * Get cart item meta - * @access public - * - * @deprecated since 3.8.13 - */ -function wpsc_get_cartmeta( $cart_item_id, $meta_key ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.13', 'wpsc_get_cart_item_meta'); - return wpsc_get_cart_item_meta( $cart_item_id, $meta_key, true ); -} - -/** - * Update cart item meta - * @access public - * - * @deprecated since 3.8.13 - */ -function wpsc_update_cartmeta( $cart_item_id, $meta_key, $meta_value ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.13', 'wpsc_update_cart_item_meta'); - return wpsc_update_cart_item_meta( $cart_item_id, $meta_key, $meta_value ); -} - -/** - * Delete cart item meta - * @access public - * - * @deprecated since 3.8.13 - */ -function wpsc_delete_cartmeta( $cart_item_id, $meta_key, $meta_value = '' ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.13', 'wpsc_delete_cart_item_meta'); - return wpsc_delete_cart_item_meta( $cart_item_id, $meta_key, $meta_value ); -} - -function wpsc_get_exchange_rate( $from, $to ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.13' ); - return _wpsc_get_exchange_rate( $from, $to ); -} - - -/** - * @access public - * @param unknown $stuff - * @param unknown $post_ID - * @return string - * @deprecated since 3.8.13.3 - */ -function wpsc_the_featured_image_fix( $stuff, $post_ID ){ - _wpsc_deprecated_function( __FUNCTION__, '3.8.13.2', 'wpsc_the_featured_image_fix'); - global $wp_query; - - $is_tax = is_tax( 'wpsc_product_category' ); - - $queried_object = get_queried_object(); - $is_single = is_single() && $queried_object->ID == $post_ID && get_post_type() == 'wpsc-product'; - - if ( $is_tax || $is_single ) { - $header_image = get_header_image(); - $stuff = ''; - - if ( $header_image ) - $stuff = ''; - } - - remove_action( 'post_thumbnail_html', 'wpsc_the_featured_image_fix' ); - - return $stuff; -} - -/** - * @access public - * @param string $meta_object_type Type of object metadata is for (e.g., variation. cart, etc) - * @return string Name of the custom meta table defined in $wpdb, or the name as it would be defined - * @deprecated since 3.8.13.4 - */ -function wpsc_meta_table_name( $meta_object_type ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.14', '_wpsc_meta_table_name' ); - return _wpsc_meta_table_name( $meta_object_type ); -} - -/** - * Google checkout not longer available or supported, so we are deprecating this function - * - * @access public - * @deprecated since 3.8.14 - */ -function wpsc_google_checkout(){ - $currpage = wpsc_selfURL(); - if (array_search("google",(array)get_option('custom_gateway_options')) !== false && $currpage != get_option('shopping_cart_url')) { - global $nzshpcrt_gateways; - foreach($nzshpcrt_gateways as $gateway) { - if($gateway['internalname'] == 'google' ) { - $gateway_used = $gateway['internalname']; - $gateway['function'](true); - } - } - } -} - -/** - * Google checkout not longer available or supported, so we are deprecating this function - * - * @access public - * @deprecated since 3.8.14 - */ -function wpsc_empty_google_logs(){ - global $wpdb; - _wpsc_deprecated_function( __FUNCTION__, '3.8.14', 'wpsc_empty_google_logs' ); - $sql = $wpdb->prepare( "DELETE FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid` = '%s'", wpsc_get_customer_meta( 'checkout_session_id' ) ); - $wpdb->query( $sql ); - wpsc_delete_customer_meta( 'checkout_session_id' ); -} - -/** - * @access public - * @deprecated since 3.8.13.4 - */ -function wpsc_user_dynamic_js() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.14', 'wpsc_javascript_localizations' ); -} - -/* - * Over time certain javascript variables that were once localized into scripts will become obsolete - * When they do moving them here will continue to create the variables for older javascript to use. - */ -function _wpsc_deprecated_javascript_localization_vars() { - - /** - * @deprecated since 3.8.14 - * - * wpsc_deprecated_vars as an object with the properties below has been replaced and each of the properties - * is available as it's own variable, that means devs instead of referencing "wpsc_ajax.base_url" do - * "base_url" - */ - - $wpsc_deprecated_js_vars = array(); - - $wpsc_deprecated_js_vars['WPSC_DIR_NAME'] = WPSC_DIR_NAME; - $wpsc_deprecated_js_vars['fileLoadingImage'] = WPSC_CORE_IMAGES_URL . '/loading.gif'; - $wpsc_deprecated_js_vars['fileBottomNavCloseImage'] = WPSC_CORE_IMAGES_URL . '/closelabel.gif'; - $wpsc_deprecated_js_vars['resizeSpeed'] = 9; // controls the speed of the image resizing (1=slowest and 10=fastest) - $wpsc_deprecated_js_vars['borderSize'] = 10; //if you adjust the padding in the CSS, you will need to update this variable - - return $wpsc_deprecated_js_vars; -} - -/** - * wpsc google checkout submit used for google checkout (unsure whether necessary in 3.8) - * @access public - * - * @deprecated since 3.8.14 - */ -function wpsc_google_checkout_submit() { - - _wpsc_deprecated_function( __FUNCTION__, '3.8.14' ); - - global $wpdb, $wpsc_cart, $current_user; - $wpsc_checkout = new wpsc_checkout(); - $purchase_log_id = $wpdb->get_var( "SELECT `id` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid` IN(%s) LIMIT 1", wpsc_get_customer_meta( 'checkout_session_id' ) ); - get_currentuserinfo(); - if ( $current_user->display_name != '' ) { - foreach ( $wpsc_checkout->checkout_items as $checkoutfield ) { - if ( $checkoutfield->unique_name == 'billingfirstname' ) { - $checkoutfield->value = $current_user->display_name; - } - } - } - if ( $current_user->user_email != '' ) { - foreach ( $wpsc_checkout->checkout_items as $checkoutfield ) { - if ( $checkoutfield->unique_name == 'billingemail' ) { - $checkoutfield->value = $current_user->user_email; - } - } - } - - $wpsc_checkout->save_forms_to_db( $purchase_log_id ); - $wpsc_cart->save_to_db( $purchase_log_id ); - $wpsc_cart->submit_stock_claims( $purchase_log_id ); -} - -/** - * - * @deprecated 3.8.14 - * @uses apply_filters() Allows manipulation of the flash upload params. - */ -function wpsc_admin_dynamic_css() { - - _wpsc_deprecated_function( __FUNCTION__, '3.8.14' ); - - header( 'Content-Type: text/css' ); - header( 'Expires: ' . gmdate( 'r', mktime( 0, 0, 0, date( 'm' ), ( date( 'd' ) + 12 ), date( 'Y' ) ) ) . '' ); - header( 'Cache-Control: public, must-revalidate, max-age=86400' ); - header( 'Pragma: public' ); - $flash = 0; - $flash = apply_filters( 'flash_uploader', $flash ); - - if ( 1 == $flash ) { -?> - div.flash-image-uploader { - display: block; - } - - div.browser-image-uploader { - display: none; - } - - div.flash-image-uploader { - display: none; - } - - div.browser-image-uploader { - display: block; - } - -
-

- a bug in WordPress prior to version 3.3, you might run into 404 errors when viewing your products. To work around this, upgrade to WordPress 3.3 or later, or simply click "Save Changes" below a second time.' , 'wp-e-commerce' ), 'http://core.trac.wordpress.org/ticket/16736', 'http://codex.wordpress.org/Updating_WordPress' ); ?> -

-
- id != 'wpsc-product' ) - return $context; - return __( 'Upload Image%s', 'wp-e-commerce' ); - - } -} - -if ( ! function_exists( 'change_link' ) ) { - function change_link( $link ) { - _wpsc_deprecated_function( __FUNCTION__, '3.8.14' ); - - global $post_ID; - $current_screen = get_current_screen(); - if ( $current_screen && $current_screen->id != 'wpsc-product' ) - return $link; - - $uploading_iframe_ID = $post_ID; - $media_upload_iframe_src = "media-upload.php?post_id=$uploading_iframe_ID"; - - return $media_upload_iframe_src . "&type=image&parent_page=wpsc-edit-products"; - } -} - -function wpsc_google_shipping_settings() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.14' ); - - if ( ! wpsc_is_store_admin() ) { - return; - } - - if ( isset( $_POST['submit'] ) ) { - foreach ( (array) $_POST['google_shipping'] as $key => $country ) { - if ( $country == 'on' ) { - $google_shipping_country[] = $key; - $updated++; - } - } - update_option( 'google_shipping_country', $google_shipping_country ); - $sendback = wp_get_referer(); - $sendback = remove_query_arg( 'googlecheckoutshipping', $sendback ); - - if ( isset( $updated ) ) { - $sendback = add_query_arg( 'updated', $updated, $sendback ); - } - - wp_redirect( esc_url_raw( $sendback ) ); - exit(); - } -} - -if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'google_shipping_settings') ) { - add_action( 'admin_init', 'wpsc_google_shipping_settings' ); -} - -function wpsc_css_header() { - _wpsc_deprecated_function( __FUNCTION__, '3.8.14' ); -} - -/** - * deprecating item filters from wpsc_display_form_fields() in release 3.8.13.4 - * - * @deprecated 3.8.14 - * - * This function displays each of the form fields. - * - * Each of them are filterable via 'wpsc_account_form_field_$tag' - * where tag is permalink-styled name or uniquename. i.e. First Name under Shipping would be - * 'wpsc_account_form_field_shippingfirstname' - while Your Billing Details would be filtered - * via 'wpsc_account_form_field_your-billing-details'. - * - * @param varies $meta_value - * @param string $meta_key - * - */ -function wpsc_user_log_deprecated_filter_values( $meta_value, $meta_key ) { - $filter = 'wpsc_account_form_field_' . $meta_key; - if ( has_filter( $filter ) ) { - $meta_value = apply_filters( $filter , esc_html( $meta_value ) ); - _wpsc_doing_it_wrong( $filter, __( 'The filter being used has been deprecated. Use wpsc_get_visitor_meta or wpsc_get_visitor_meta_$meta_name instead.', 'wp-e-commerce' ), '3.8.14' ); - } - - return $meta_value; -} -add_filter( 'wpsc_get_visitor_meta', 'wpsc_user_log_deprecated_filter_values', 10, 2 ); - -/** - * deprecating user log filter for getting all customer meta as an array. - * - *@deprecated 3.8.14 - * - * @return none - */ -function wpsc_deprecated_filter_user_log_get() { - if ( has_filter( 'wpsc_user_log_get' ) ) { - $meta_data = wpsc_get_customer_meta( 'checkout_details' ); - $meta_data = apply_filters( 'wpsc_user_log_get', $meta_data, wpsc_get_current_customer_id() ); - wpsc_update_customer_meta( 'checkout_details', $meta_data ); - _wpsc_doing_it_wrong( 'wpsc_user_log_get', __( 'The filter being used has been deprecated. Use wpsc_get_visitor_meta or wpsc_get_visitor_meta_$meta_name instead.', 'wp-e-commerce' ), '3.8.14' ); - } -} - -add_action( 'wpsc_start_display_user_log_form_fields', 'wpsc_deprecated_filter_user_log_get', 10, 0 ); - - -/** - * function to provide deprecated variables to older shipping modules - * - * @since 3.8.14 - */ -function wpsc_deprecated_vars_for_shipping( $wpsc_cart ) { - // extracted from the Instinct fedex module - $_POST['country'] = wpsc_get_customer_meta( 'shippingcountry' ); - $_POST['region'] = wpsc_get_customer_meta( 'shippingregion' ); - $_POST['zipcode'] = wpsc_get_customer_meta( 'shippingpostcode' ); -} - -add_action( 'wpsc_before_get_shipping_method', 'wpsc_deprecated_vars_for_shipping' ); - -function _wpsc_action_user_update_errors( $errors, $update, $user ) { - if ( isset( $user->role ) && $user->role == 'wpsc_anonymous' ) { - unset( $errors->errors['empty_email'] ); - } -} - -// add_action( 'user_profile_update_errors', '_wpsc_action_user_update_errors', 10, 3 ); - -/** - * Not yet deprecated, but should be considered deprecated. - * - * Used only in TEv1 user account page. - * - * @param $selected_country - * @return - */ -function nzshpcrt_country_list( $selected_country = null ) { - return _wpsc_country_dropdown_options( array( - 'selected' => $selected_country, - ) ); -} - -/** - * Not yet deprecated, but should be considered deprecated. - * - * Used only in TEv1 user account page. - * - * @param [type] $selected_country [description] - * @param [type] $selected_region [description] - * @return [type] [description] - */ -function nzshpcrt_region_list( $selected_country = null, $selected_region = null ) { - global $wpdb; - - if ( $selected_region == null ) - $selected_region = get_option( 'base_region' ); - - $output = ''; - $region_list = WPSC_Countries::get_regions( $selected_country, true ); - - if ( $region_list != null ) { - foreach ( $region_list as $region ) { - if ( $selected_region == $region['id'] ) { - $selected = "selected='selected'"; - } else { - $selected = ""; - } - - $output .= "\r\n"; - } - } else { - $output .= "\r\n"; - } - - return $output; -} - -/** - * Not yet deprecated, but should be considered deprecated. - * - * Used only in PayPal Standard and Chronopay gateways. - * - * @param [type] $selected_field [description] - * @return [type] [description] - */ -function nzshpcrt_form_field_list( $selected_field = null ) { - global $wpdb; - $output = ""; - $form_sql = "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1';"; - $form_data = $wpdb->get_results( $form_sql, ARRAY_A ); - - foreach ( (array)$form_data as $form ) { - $selected = ''; - if ( $selected_field == $form['id'] ) { - $selected = "selected='selected'"; - } - $output .= ""; - } - - return $output; -} - -function wpsc_sanitise_keys($value) { - _wpsc_deprecated_function( __FUNCTION__, '4.0' ); - /// Function used to cast array items to integer. - return (int)$value; -} - -/** - * Duplicates a product - * - * @uses WPSC_Duplicate_Product Duplicate product class. - * - * @param object $post The post object. - * @param int|bool $new_parent_id Optional. The parent post ID or false. - * @return int|WP_Error New post ID or error. - * - * @deprecated since 4.0 - */ -function wpsc_duplicate_product_process( $post, $new_parent_id = false ) { - - _wpsc_deprecated_function( __FUNCTION__, '4.0', 'WPSC_Duplicate_Product->duplicate_product_process()' ); - - $duplicate = new WPSC_Duplicate_Product( $post->ID, $new_parent_id ); - - return $duplicate->duplicate_product_process(); - -} - -/** - * Copy the taxonomies of a post to another post - * - * @uses WPSC_Duplicate_Product Duplicate product class. - * - * @param int $id ID of the post we are duping. - * @param int $new_id ID of the new post. - * @param string $post_type The post type we are setting. - * - * @deprecated since 4.0 - */ -function wpsc_duplicate_taxonomies( $id, $new_id, $post_type ) { - - _wpsc_deprecated_function( __FUNCTION__, '4.0', 'WPSC_Duplicate_Product->duplicate_taxonomies()' ); - - $duplicate = new WPSC_Duplicate_Product( $id, false, $new_id ); - $duplicate->duplicate_taxonomies(); - -} - -/** - * Copy the meta information of a post to another post - * - * @uses WPSC_Duplicate_Product Duplicate product class. - * - * @param int $id ID of the post we are duping. - * @param int $new_id ID of the new post. - * - * @deprecated since 4.0 - */ -function wpsc_duplicate_product_meta( $id, $new_id ) { - - _wpsc_deprecated_function( __FUNCTION__, '4.0', 'WPSC_Duplicate_Product->duplicate_product_meta()' ); - - $duplicate = new WPSC_Duplicate_Product( $id, false, $new_id ); - $duplicate->duplicate_product_meta(); - -} - -/** - * Update Duplicate Product Gallery Meta - * - * When a product is duplicated it's meta values are copied too - * including the gallery meta array of IDs. - * - * After the product's children (including attachments) have been - * duplicated this function is used to update the gallery meta to - * refer to the IDs of any duplicated media. - * - * @param int $post_id Original product post ID. - * @param int $new_post_id Duplicated product post ID. - * @param array $duplicated_children Associative array mapping original child IDs to duplicated child IDs. - * - * @deprecated since 4.0 - */ -function wpsc_update_duplicate_product_gallery_meta( $post_id, $new_post_id, $duplicated_children ) { - - _wpsc_deprecated_function( __FUNCTION__, '4.0' ); - -} - -/** - * Duplicate Featured Image - * - * When a product is duplicated, the featured image ID is copied when the post - * meta is duplicated. - * - * When the featured image is attached to the duplicated product, if the image - * is duplicated the featured image ID is updated to the duplicated image ID - * otherwise the featured image ID is removed. - * - * If the featured image is not attached to the product the featured image ID - * remains the same as the original product. - * - * This function will remove the featured image if the image is not attached to - * the duplicated product and offers the opportunity to change the featured image - * of the duplicated product via the 'wpsc_duplicate_product_thumbnail' filter. - * - * @uses WPSC_Duplicate_Product Duplicate product class. - * - * @param integer $post_id Product ID. - * @param integer $new_post_id Duplicated product ID. - * - * @deprecated since 4.0 - */ -function wpsc_duplicate_product_thumbnail( $post_id, $new_post_id ) { - - _wpsc_deprecated_function( __FUNCTION__, '4.0', 'WPSC_Duplicate_Product->duplicate_product_thumbnail()' ); - - $duplicate = new WPSC_Duplicate_Product( $post_id, false, $new_post_id ); - $duplicate->duplicate_product_thumbnail(); - -} - -/** - * Duplicates product children and meta - * - * @uses WPSC_Duplicate_Product Duplicate product class. - * - * @param int $old_parent_id Post id for old parent. - * @param int $new_parenc_id Post id for the new parent. - * @return array Array mapping old child IDs to duplicated child IDs. - * - * @deprecated since 4.0 - */ -function wpsc_duplicate_children( $old_parent_id, $new_parent_id ) { - - _wpsc_deprecated_function( __FUNCTION__, '4.0', 'WPSC_Duplicate_Product->duplicate_children()' ); - - $duplicate = new WPSC_Duplicate_Product( $old_parent_id, false, $new_parent_id ); - - return $duplicate->duplicate_children(); - -} - -/** - * Duplicates a product image. - * - * Uses a portion of code from media_sideload_image() in `wp-admin/includes/media.php` - * to check file before downloading from URL. - * - * @since 3.9.0 - * - * @uses WPSC_Duplicate_Product Duplicate product class. - * - * @param object $post The post object. - * @param bool $new_parent_id The parent post id. - * @return int|bool Attachment ID or false. - * - * @deprecated since 4.0 - */ -function wpsc_duplicate_product_image_process( $child_post, $new_parent_id ) { - - _wpsc_deprecated_function( __FUNCTION__, '4.0', 'WPSC_Duplicate_Product->duplicate_product_image_process()' ); - - $duplicate = new WPSC_Duplicate_Product( $child_post->ID, $new_parent_id ); - $duplicate->duplicate_product_image_process(); - -} - -/** - * Fancy Notifications - * - * @deprecated Since 4.0. Use WPSC_Fancy_Notifications::fancy_notifications() instead. - * - * @uses WPSC_Fancy_Notifications Fancy notifications class. - * - * @return string Fancy Notification HTML. - */ -function fancy_notifications() { - - return WPSC_Fancy_Notifications::fancy_notifications( true ); - -} - -/** - * Fancy Notifications - * - * @deprecated Since 4.0. Use WPSC_Fancy_Notifications::fancy_notifications() instead. - * - * @uses WPSC_Fancy_Notifications Fancy notifications class. - * - * @param boolean $return Return or echo. - * @return string Fancy Notification HTML. - */ -function wpsc_fancy_notifications( $return = false ) { - - if ( $return ) { - return WPSC_Fancy_Notifications::fancy_notifications( $return ); - } else { - echo WPSC_Fancy_Notifications::fancy_notifications( $return ); - } - -} - -/** - * Fancy Notification Content - * - * @deprecated Since 4.0. Use WPSC_Fancy_Notifications::fancy_notification_content() instead. - * - * @uses WPSC_Fancy_Notifications Fancy notifications class. - * - * @param array $cart_messages Cart messages. - * @return array Cart messages. - */ -function fancy_notification_content( $cart_messages ) { - - return WPSC_Fancy_Notifications::fancy_notification_content( $cart_messages ); - -} From 1380802bdb1f971dbf6b948e389f55cedee180a2 Mon Sep 17 00:00:00 2001 From: andy-1977 <61007039+andy-1977@users.noreply.github.com> Date: Thu, 18 Feb 2021 13:34:26 +0000 Subject: [PATCH 11/17] Delete cart-template-api.php --- wpsc-includes/cart-template-api.php | 663 ---------------------------- 1 file changed, 663 deletions(-) delete mode 100644 wpsc-includes/cart-template-api.php diff --git a/wpsc-includes/cart-template-api.php b/wpsc-includes/cart-template-api.php deleted file mode 100644 index b7e7e656de..0000000000 --- a/wpsc-includes/cart-template-api.php +++ /dev/null @@ -1,663 +0,0 @@ -needs_shipping_recalc(); - } - - return $result; -} - -/** - * Clear all shipping method information for the current customer cart - * - * @since 3.8.14 - * - * @uses wpsc_cart - * - */ -function wpsc_cart_clear_shipping_info() { - global $wpsc_cart; - - if ( _wpsc_verify_global_cart_has_been_initialized( __FUNCTION__ ) ) { - $wpsc_cart->clear_shipping_info(); - } -} - -/** - * tax is included function - * - * @uses wpec_taxes_controller - * - * @return boolean true or false depending on settings>general page - */ -function wpsc_tax_isincluded() { - //uses new wpec_taxes functionality now - - require_once( WPSC_FILE_PATH . '/wpsc-taxes/taxes_module.php' ); - - $wpec_taxes_controller = new wpec_taxes_controller(); - return $wpec_taxes_controller->wpec_taxes_isincluded(); -} - -/** - * cart item count function - * - * @uses wpsc_cart - * - * @return integer the item count - */ -function wpsc_cart_item_count() { - global $wpsc_cart; - - $count = 0; - - if ( _wpsc_verify_global_cart_has_been_initialized( __FUNCTION__ ) ) { - foreach ( (array)$wpsc_cart->cart_items as $cart_item ) { - $count += $cart_item->quantity; - } - } - - return $count; -} - -/** - * coupons price, used through ajax and in normal page loading. - * No parameters, returns nothing - */ -function wpsc_coupon_price( $currCoupon = '' ) { - global $wpsc_cart, $wpsc_coupons; - if ( isset( $_POST['coupon_num'] ) && $_POST['coupon_num'] != '' ) { - $coupon = esc_sql( $_POST['coupon_num'] ); - wpsc_update_customer_meta( 'coupon', $coupon ); - $wpsc_coupons = new wpsc_coupons( $coupon ); - - if ( $wpsc_coupons->validate_coupon() ) { - $discountAmount = $wpsc_coupons->calculate_discount(); - $wpsc_cart->apply_coupons( $discountAmount, $coupon ); - $wpsc_coupons->errormsg = false; - } else { - $wpsc_coupons->errormsg = true; - $wpsc_cart->coupons_amount = 0; - $wpsc_cart->coupons_name = ''; - wpsc_delete_customer_meta( 'coupon' ); - } - } else if ( (!isset( $_POST['coupon_num'] ) || $_POST['coupon_num'] == '') && $currCoupon == '' ) { - $wpsc_cart->coupons_amount = 0; - $wpsc_cart->coupons_name = ''; - } else if ( $currCoupon != '' ) { - $coupon = esc_sql( $currCoupon ); - wpsc_update_customer_meta( 'coupon', $coupon ); - $wpsc_coupons = new wpsc_coupons( $coupon ); - - if ( $wpsc_coupons->validate_coupon() ) { - $discountAmount = $wpsc_coupons->calculate_discount(); - $wpsc_cart->apply_coupons( $discountAmount, $coupon ); - $wpsc_coupons->errormsg = false; - } - } -} - -/** - * Get WPEC cart coupon value total - * - * @param boolean $format_for_display should the output formatted for display, or returned as a number - * - * @uses wpsc_cart - * - * @return integer the item count - */ -function wpsc_coupon_amount( $format_for_display = true ) { - global $wpsc_cart; - - $output = ''; - - if ( _wpsc_verify_global_cart_has_been_initialized( __FUNCTION__ ) ) { - if ( $format_for_display ) { - $output = wpsc_currency_display( $wpsc_cart->coupons_amount ); - } else { - $output = $wpsc_cart->coupons_amount; - } - } - - return $output; -} - -/** - * cart total function - * - * @param boolean $format_for_display should the output formatted for display, or returned as a number - * - * @uses wpsc_cart - * - * @return string the total price of the cart, with a currency sign - */ -function wpsc_cart_total( $format_for_display = true ) { - global $wpsc_cart; - $total = 0; - - if ( _wpsc_verify_global_cart_has_been_initialized( __FUNCTION__ ) ) { - - $total = $wpsc_cart->calculate_total_price(); - - if ( $format_for_display ) { - $total = wpsc_currency_display( $total ); - } - } - - return $total; -} - -/** - * nzshpcrt_overall_total_price function - * - * @uses wpsc_cart - * - * @return string the total price of the cart, with a currency sign, empty string on failure - */ -function nzshpcrt_overall_total_price() { - - global $wpsc_cart; - - if ( _wpsc_verify_global_cart_has_been_initialized( __FUNCTION__ ) ) { - return $wpsc_cart->calculate_total_price(); - } else { - return ''; - } - -} - -/** - * cart total weight function - * - * @uses wpsc_cart - * - * @return float the total weight of the cart - */ -function wpsc_cart_weight_total() { - global $wpsc_cart; - - if ( _wpsc_verify_global_cart_has_been_initialized( __FUNCTION__ ) ) { - return $wpsc_cart->calculate_total_weight( true ); - } else { - return 0.0; - } -} - -/** - * tax total function, no parameters - * - * @uses wpsc_cart - * - * @return float the total weight of the cart - */ -function wpsc_cart_tax( $format_for_display = true ) { - global $wpsc_cart; - - $cart_tax = $format_for_display ? '' : 0; - - if ( _wpsc_verify_global_cart_has_been_initialized( __FUNCTION__ ) ) { - if ( $format_for_display ) { - if ( ! wpsc_tax_isincluded() ) { - $cart_tax = wpsc_currency_display( $wpsc_cart->calculate_total_tax() ); - } else { - $cart_tax = '(' . wpsc_currency_display( $wpsc_cart->calculate_total_tax() ) . ')'; - } - } else { - $cart_tax = $wpsc_cart->calculate_total_tax(); - } - } - - return $cart_tax; -} - - -/** - * wpsc_cart_show_plus_postage function, no parameters - * For determining whether to show "+ Postage & tax" after the total price - * - * @uses wpsc_cart - * - * @return boolean true or false - */ -function wpsc_cart_show_plus_postage() { - - // TODO: Deprecate the use of $_SESSION for cart state, see github issue report #997 - // https://github.com/wp-e-commerce/WP-e-Commerce/issues/997 - if ( - isset( $_SESSION['wpsc_has_been_to_checkout'] ) - && ($_SESSION['wpsc_has_been_to_checkout'] == null ) - && ( get_option( 'add_plustax' ) == 1 - ) ) { - - return true; - - } else { - return false; - } -} - -/** - * Does the customers cart require/user shipping - * - * @uses wpsc_cart - * @return boolean if true, all items in the cart do use shipping - */ -function wpsc_uses_shipping() { - - //This currently requires - global $wpsc_cart; - - $shippingoptions = get_option( 'custom_shipping_options' ); - - if ( get_option( 'do_not_use_shipping' ) ) { - return false; - } - - $uses_shipping = false; - - if ( _wpsc_verify_global_cart_has_been_initialized( __FUNCTION__ ) ) { - - if ( ( ! ( ( get_option( 'shipping_discount' ) == 1 ) && ( get_option( 'shipping_discount_value' ) <= $wpsc_cart->calculate_subtotal() ) ) ) - || ( count( $shippingoptions ) >= 1 && $shippingoptions[0] != '') - ) { - $uses_shipping = (bool) $wpsc_cart->uses_shipping(); - } else { - $uses_shipping = false; - } - } - - return $uses_shipping; -} - -/** - * Check if the shipping charges are non-zero for the customer cart - * - * @uses wpsc_cart - * - * @return boolean true for yes, false for no - */ -function wpsc_cart_has_shipping() { - global $wpsc_cart; - - $has_shipping = false; - - if ( _wpsc_verify_global_cart_has_been_initialized( __FUNCTION__ ) ) { - if ( $wpsc_cart->calculate_total_shipping() > 0 ) { - $has_shipping = true; - } else { - $has_shipping = false; - } - } - - return $has_shipping; -} - - -/** - * Checks if the store has shipping enabled globally. - * - * @since 3.8.14.1 - * @return bool Whether or not shipping is enabled. - */ -function wpsc_is_shipping_enabled() { - return ! (bool) get_option( 'do_not_use_shipping', false ); -} - -/** - * Get cart total - * - * @uses wpsc_cart - * - * @return string the total shipping of the cart, with a currency sign - */ -function wpsc_cart_shipping() { - global $wpsc_cart; - - if ( _wpsc_verify_global_cart_has_been_initialized( __FUNCTION__ ) ) { - $result = wpsc_currency_display( $wpsc_cart->calculate_total_shipping() ); - } else { - $result = ''; - } - - $result = apply_filters( 'wpsc_cart_shipping', $result ); - - return $result; -} - - -/** - * Get cart item categories function - * - * @since - * @uses wpsc_cart - * - * @return array array of the categories - */ -function wpsc_cart_item_categories( $get_ids = false ) { - global $wpsc_cart; - - $categories = array(); - - if ( _wpsc_verify_global_cart_has_been_initialized( __FUNCTION__ ) ) { - if ( $get_ids ) { - $categories = $wpsc_cart->get_item_category_ids(); - } else { - $categories = $wpsc_cart->get_item_categories(); - } - } - - return $categories; -} - -/** - * Product Maximum Cart Quantity - * - * @since 3.8.10 - * @access public - * - * @param int $prod_id Optional. Product ID. - * @return int The maximum quantity that can be added to the cart. - * - * @uses apply_filters Calls 'wpsc_product_max_cart_quantity' passing product ID. - */ -function wpsc_product_max_cart_quantity( $product_id = 0 ) { - $product_id = absint( $product_id ); - return apply_filters( 'wpsc_product_max_cart_quantity', 10000, $product_id ); -} - -/** - * Product Minimum Cart Quantity - * - * @since 3.8.13 - * @access public - * - * @param int $prod_id Optional. Product ID. - * @return int The minimum quantity that can be added to the cart. - * - * @uses apply_filters Calls 'wpsc_product_min_cart_quantity' passing product ID. - */ -function wpsc_product_min_cart_quantity( $product_id = 0 ) { - $product_id = absint( $product_id ); - return apply_filters( 'wpsc_product_min_cart_quantity', 1, $product_id ); -} - -/** - * Validate Product Cart Quantity - * Checks that the quantity is within the permitted bounds and return a valid quantity. - * - * @since 3.8.10 - * @access public - * - * @param int $quantity Cart item product quantity. - * @param int $prod_id Optional. Product ID. - * @return int The maximum quantity that can be added to the cart. - * - * @uses wpsc_product_max_cart_quantity Gets the maximum product cart quantity. - * @uses wpsc_product_min_cart_quantity Gets the minimum product cart quantity. - * @uses wpsc_cart - */ -function wpsc_validate_product_cart_quantity( $quantity, $product_id = 0 ) { - - $max_quantity = wpsc_product_max_cart_quantity( $product_id ); - $min_quantity = wpsc_product_min_cart_quantity( $product_id ); - - if ( $quantity > $max_quantity ) { - return $max_quantity; - } - - if ( $quantity < $min_quantity ) { - return $min_quantity; - } - - return $quantity; -} - -/** - * Validate Cart Product Quantity - * Triggered by 'wpsc_add_item' and 'wpsc_edit_item' actions when products are added to the cart. - * - * @since 3.8.10 - * @access private - * - * @param int $product_id Cart product ID. - * @param array $parameters Cart item parameters. - * @param object $cart Cart object. - * - * @uses wpsc_cart - * @uses wpsc_validate_product_cart_quantity Filters and restricts the product cart quantity. - */ -function _wpsc_validate_cart_product_quantity( $product_id, $parameters, $cart ) { - foreach ( $cart->cart_items as $key => $cart_item ) { - if ( $cart_item->product_id == $product_id ) { - $cart->cart_items[ $key ]->quantity = wpsc_validate_product_cart_quantity( $cart->cart_items[ $key ]->quantity, $product_id ); - $cart->cart_items[ $key ]->refresh_item(); - } - } -} - -add_action( 'wpsc_add_item' , '_wpsc_validate_cart_product_quantity', 10, 3 ); -add_action( 'wpsc_edit_item', '_wpsc_validate_cart_product_quantity', 10, 3 ); - -/** - * cart all shipping quotes, used for google checkout - * returns all the quotes for a selected shipping method - * - * @since - * @access public - * - * @uses wpsc_cart - * - * @return array of shipping options -*/ -function wpsc_selfURL() { - $s = empty( $_SERVER ['HTTPS'] ) ? '' : ( $_SERVER ['HTTPS'] == 'on' ) ? 's' : ''; - $protocol = wpsc_strleft( strtolower( $_SERVER ['SERVER_PROTOCOL'] ), '/' ) . $s; - $port = ( $_SERVER ['SERVER_PORT'] == '80' ) ? '' : ( ':' . $_SERVER ['SERVER_PORT'] ); - return $protocol . '://' . $_SERVER ['SERVER_NAME'] . $port . $_SERVER ['REQUEST_URI']; -} - -function wpsc_strleft( $s1, $s2 ) { - $values = substr( $s1, 0, strpos( $s1, $s2 ) ); - return $values; -} - -/** - * WPEC cart API template function - * - * @since - * - * @param - * - * @uses wpsc_cart - */ -function wpsc_update_shipping_single_method(){ - global $wpsc_cart; - - if ( _wpsc_verify_global_cart_has_been_initialized( __FUNCTION__ ) ) { - if ( ! empty( $wpsc_cart->shipping_method ) ) { - $wpsc_cart->update_shipping( $wpsc_cart->shipping_method, $wpsc_cart->selected_shipping_option ); - } - } -} - -/** - * WPEC cart API template function - * - * @since - * - * @param - * - * @uses wpsc_cart - */ -function wpsc_update_shipping_multiple_methods(){ - global $wpsc_cart; - - if ( _wpsc_verify_global_cart_has_been_initialized( __FUNCTION__ ) ) { - if ( ! empty( $wpsc_cart->selected_shipping_method ) ) { - $wpsc_cart->update_shipping( $wpsc_cart->selected_shipping_method, $wpsc_cart->selected_shipping_option ); - } - } -} - -/** - * Get remaining product quantity - * - * @since - * @access public - * - * @param int $product_id Cart product ID. - * @param array $variations Cart item parameters. - * @param int $quantity Cart object. - * - * @uses wpsc_product_stock Filters and restricts the product cart quantity. - */ -function wpsc_get_remaining_quantity( $product_id, $variations = array(), $quantity = 1 ) { - - $stock = get_post_meta( $product_id, '_wpsc_stock', true ); - $stock = apply_filters( 'wpsc_product_stock', $stock, $product_id ); - $output = 0; - - // check to see if the product uses stock - if ( is_numeric( $stock ) ) { - - if ( $stock > 0 ) { - $claimed_query = new WPSC_Claimed_Stock( array( 'product_id' => $product_id ) ); - $claimed_stock = $claimed_query->get_claimed_stock_count(); - $output = $stock - $claimed_stock; - } - } - - return $output; -} - -/** - * Prior to using the global cart variable cart template API functions should check - * to be sure the global cart variable has been initialized. - * - * @access private - * @static - * @since 3.8.14 - * - * @uses wpsc_cart - * @return boolean true if we have a valid cart, false otherwise - * - */ -function _wpsc_verify_global_cart_has_been_initialized( $function = __FUNCTION__ ) { - - global $wpsc_cart; - - $we_have_a_valid_cart = ! empty( $wpsc_cart ) && is_a( $wpsc_cart, 'wpsc_cart' ); - - if ( ! $we_have_a_valid_cart ) { - $wpsc_cart = wpsc_get_customer_cart(); - $we_have_a_valid_cart = ! empty( $wpsc_cart ) && is_a( $wpsc_cart, 'wpsc_cart' ); - } - - // We will try to give a helpful message to the developer so that they can adjust their code - static $already_gave_no_valid_cart_message = false; - if ( ! $we_have_a_valid_cart && ! $already_gave_no_valid_cart_message ) { - _wpsc_doing_it_wrong( $function, __( 'The WPeC global cart is not yet initialized. Accessing global cart properties and methods will not work.', 'wp-e-commerce' ), '3.8.14' ); - $already_gave_no_valid_cart_message = true; - } - - return $we_have_a_valid_cart; -} - -/** - * Checks if the current cart is a "Free Cart", which means one of the following: - * - * - Either the all of the cart items are priced at 0. - * - Or a coupon has been applied that results in a free cart. - * - * This is a helpful function for doing things like allowing free carts to be purchased, bypassing payment gateways. - * - * @since 3.9.0 - * @return bool Whether or not the current cart's total cost is free or not. - */ -function wpsc_is_free_cart() { - return apply_filters( 'wpsc_is_free_cart', wpsc_cart_item_count() && ! floatval( wpsc_cart_total( false ) ) ); -} - -/** - * Allows users to checkout with a free cart. - * - * If developers or users would rather inhibit this functionality, as it was prior to 3.9.0, they can - * add the following code (prior to 'init', priority 2) to a theme or plugin: - * add_filter( 'wpsc_allow_free_cart_checkout', '__return_false' ); - * - * @since 3.9.0 - * @return void - */ -function wpsc_allow_free_cart_checkout() { - - if ( wpsc_is_free_cart() && apply_filters( 'wpsc_allow_free_cart_checkout', true ) ) { - - /* Required for compatibility with the 3.0 payment gateway API and the 2.0 theme engine */ - add_filter( 'wpsc_payment_method_form_fields', '__return_empty_array' ); - - /* Sets the status entered to the "Accepted Payment" status and sets a 'free' gateway name. */ - add_filter( 'wpsc_purchase_log_insert_data', 'wpsc_free_checkout_insert_order_status' ); - - /* Handles what a gateway would properly handle, updating the "processed" key in the database. */ - add_action( 'wpsc_submit_checkout_gateway', 'wpsc_free_checkout_update_processed_status', 5, 2 ); - } - -} - -add_action( 'init', 'wpsc_allow_free_cart_checkout', 2 ); - -/** - * Updates the 'statusno' and 'gateway' parameters when a new order is submitted with a free cart. - * - * @param array $data Array of arguments passed to WPSC_Purchase_Log on a new order. - * @uses apply_filters 'wpsc_free_checkout_order_status' allows developers to change the status a free cart is saved with. - * @uses apply_filters 'wpsc_free_checkout_order_gateway' allows developers to change the gateway a free cart is saved with - * @since 3.9.0 - * - * @return array $data Modified array of arguments passed to WPSC_Purchase_Log on a new order. - */ -function wpsc_free_checkout_insert_order_status( $data ) { - $data['statusno'] = apply_filters( 'wpsc_free_checkout_order_status', WPSC_Purchase_Log::ACCEPTED_PAYMENT ); - $data['gateway'] = apply_filters( 'wpsc_free_checkout_order_gateway', 'free' ); - - return $data; -} - -/** - * Updates the 'processed' parameter after a new order is submitted with a free cart. - * - * @param string $gateway Name of gateway. In the case of a free cart, this will be empty. - * @param WPSC_Purchase_Log $log WPSC_Purchase_Log object. - * @uses apply_filters 'wpsc_free_checkout_order_status' allows developers to change the status a free cart is saved with. - * @since 3.9.0 - * - */ -function wpsc_free_checkout_update_processed_status( $gateway, $log ) { - - wpsc_update_purchase_log_status( - $log->get( 'id' ), - apply_filters( 'wpsc_free_checkout_order_status', WPSC_Purchase_Log::ACCEPTED_PAYMENT ) - ); - - wp_safe_redirect( add_query_arg( 'sessionid', $log->get( 'sessionid' ), get_option( 'transact_url' ) ) ); - exit; -} From 2570cad2bd3f5038b67d2b29c0484cd08b428159 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 18 Feb 2021 14:38:22 +0000 Subject: [PATCH 12/17] Revert "Delete product.php" This reverts commit 7f1a916d71f51be54522b58c29f508aad84986fc. --- .../theme-engine-v1/helpers/product.php | 848 ++++++++++++++++++ 1 file changed, 848 insertions(+) create mode 100644 wpsc-components/theme-engine-v1/helpers/product.php diff --git a/wpsc-components/theme-engine-v1/helpers/product.php b/wpsc-components/theme-engine-v1/helpers/product.php new file mode 100644 index 0000000000..b8bad28122 --- /dev/null +++ b/wpsc-components/theme-engine-v1/helpers/product.php @@ -0,0 +1,848 @@ +ID; + } else { + // In wordpress 3.0 we get a post ID + $post_id = $post; + $post = get_post( $post_id ); + } + + // Only applies to WPSC products, don't stop on permalinks of other CPTs + // Fixes http://code.google.com/p/wp-e-commerce/issues/detail?id=271 + if ( 'wpsc-product' !== $post->post_type ) { + return $permalink; + } + + if ( 'inherit' === $post->post_status && 0 !== $post->post_parent ) { + $post_id = $post->post_parent; + $post = get_post( $post_id ); + } + + global $wp_rewrite; + + $our_permalink_structure = $wp_rewrite->root; + + // This may become customiseable later + $our_permalink_structure .= str_replace( basename( home_url() ), '', $wpsc_page_titles['products'] ) . "/%wpsc_product_category%/%postname%/"; + + // Mostly the same conditions used for posts, but restricted to items with a post type of "wpsc-product " + if ( $wp_rewrite->using_permalinks() && ! in_array( $post->post_status, array( 'draft', 'pending' ) ) ) { + + $product_categories = wpsc_get_product_terms( $post_id, 'wpsc_product_category' ); + $product_category_slugs = array( ); + foreach ( $product_categories as $product_category ) { + $product_category_slugs[] = $product_category->slug; + } + // If the product is associated with multiple categories, determine which one to pick + if ( count( $product_categories ) == 0 ) { + $category_slug = apply_filters( 'wpsc_uncategorized_product_category', 'uncategorized' ); + } elseif ( count( $product_categories ) > 1 ) { + if ( (isset( $wp_query->query_vars['products'] ) && $wp_query->query_vars['products'] != null) && in_array( $wp_query->query_vars['products'], $product_category_slugs ) ) { + $product_category = $wp_query->query_vars['products']; + } else { + $link = $product_categories[0]->slug; + if ( ! in_array( 'wp_head', $wp_current_filter) && isset( $wpsc_query->query_vars['wpsc_product_category'] ) ) { + $current_cat = $wpsc_query->query_vars['wpsc_product_category']; + if ( in_array( $current_cat, $product_category_slugs ) ) + $link = $current_cat; + } + + $product_category = $link; + } + $category_slug = $product_category; + } else { + // If the product is associated with only one category, we only have one choice + if ( !isset( $product_categories[0] ) ) + $product_categories[0] = ''; + + $product_category = $product_categories[0]; + + if ( !is_object( $product_category ) ) + $product_category = new stdClass(); + + if ( !isset( $product_category->slug ) ) + $product_category->slug = null; + + $category_slug = $product_category->slug; + } + + $post_name = $post->post_name; + + if ( get_option( 'product_category_hierarchical_url', 0 ) ) { + $selected_term = get_term_by( 'slug', $category_slug, 'wpsc_product_category' ); + if ( is_object( $selected_term ) ) { + $term_chain = array( $selected_term->slug ); + while ( $selected_term->parent ) { + $selected_term = get_term( $selected_term->parent, 'wpsc_product_category' ); + array_unshift( $term_chain, $selected_term->slug ); + } + $category_slug = implode( '/', $term_chain ); + } + } + + if( isset( $category_slug ) && empty( $category_slug ) ) + $category_slug = 'product'; + + $category_slug = apply_filters( 'wpsc_product_permalink_cat_slug', $category_slug, $post_id ); + + $rewritereplace = array( + $category_slug, + $post_name + ); + + $permalink = str_replace( $rewritecode, $rewritereplace, $our_permalink_structure ); + $permalink = user_trailingslashit( $permalink, 'single' ); + + $permalink = home_url( $permalink ); + } + + return apply_filters( 'wpsc_product_permalink', $permalink, $post->ID ); +} + +/** + * wpsc_list_categories function. + * + * @access public + * @param string $callback_function - The function name you want to use for displaying the data + * @param mixed $parameters (default: null) - the additional parameters to the callback function + * @param int $category_id. (default: 0) - The category id defaults to zero, for displaying all categories + * @param int $level. (default: 0) + */ +function wpsc_list_categories($callback_function, $parameters = null, $category_id = 0, $level = 0) { + global $wpdb,$category_data; + $output = ''; + $category_list = get_terms('wpsc_product_category','hide_empty=0&parent='.$category_id); + if($category_list != null) { + foreach((array)$category_list as $category) { + $callback_output = $callback_function($category, $level, $parameters); + if(is_array($callback_output)) { + $output .= array_shift($callback_output); + } else { + $output .= $callback_output; + } + $output .= wpsc_list_categories($callback_function, $parameters , $category->term_id, ($level+1)); + if(is_array($callback_output) && (isset($callback_output[1]))) { + $output .= $callback_output[1]; + } + } + } + return $output; +} + +/** +* Gets the Function Parent Image link and checks whether Image should be displayed or not +* +*/ +function wpsc_parent_category_image($show_thumbnails , $category_image , $width, $height, $grid=false, $show_name){ + + if(!$show_thumbnails) return; + + if($category_image == WPSC_CATEGORY_URL){ + if(!$show_name) return; + ?> + + + + + + $start_element, 'end_element' => $end_element); + echo "[wpsc_category_description]"; +} + +/** +* wpsc print category url function +* places the shortcode for the category URL +*/ +function wpsc_print_category_url() { + echo "[wpsc_category_url]"; +} + +/** +* wpsc print category id function +* places the shortcode for the category URL +*/ +function wpsc_print_category_id() { + echo "[wpsc_category_id]"; +} + +/** +* wpsc print category classes function +* places classes for the category including selected state +* +* please note that "current category" means the category that we are in now, +* and not the category that we are printing for +* +* @param $category_to_print - the category for which we should print classes +* @param $echo - whether to echo the result (true) or return (false) +*/ +function wpsc_print_category_classes($category_to_print = false, $echo = true) { + global $wp_query, $wpdb; + $result = ''; + + //if we are in wpsc category page then get the current category + $curr_cat = false; + $term = get_query_var( 'wpsc_product_category' ); + if ( ! $term && get_query_var( 'taxonomy' ) == 'wpsc_product_category' ) + $term = get_query_var( 'term' ); + if ( $term ) + $curr_cat = get_term_by( 'slug', $term, 'wpsc_product_category' ); + + //check if we are in wpsc category page and that we have a term_id of the category to print + //this is done here because none of the following matters if we don't have one of those and we can + //safely return + if(isset($category_to_print['term_id']) && $curr_cat){ + + //we will need a list of current category parents for the following if statement + $curr_cat_parents = wpsc_get_term_parents($curr_cat->term_id, 'wpsc_product_category'); + + //if current category is the same as the one we are printing - then add wpsc-current-cat class + if( $category_to_print['term_id'] == $curr_cat->term_id ) + $result = ' wpsc-current-cat '; + //else check if the category that we are printing is parent of current category + elseif ( in_array($category_to_print['term_id'], $curr_cat_parents) ) + $result = ' wpsc-cat-ancestor '; + } + + $result = apply_filters( 'wpsc_print_category_classes', $result, $category_to_print ); + + if ( ! empty ( $result ) ) { + if ( $echo ) { + echo $result; + } else { + return $result; + } + } +} + +/** +* wpsc print subcategory function +* places the shortcode for the subcategories, accepts parameters for the subcategories container, have this as
    and
if using a list +* @param string starting HTML element +* @param string ending HTML element +*/ +function wpsc_print_subcategory($start_element = '', $end_element = '') { + global $wpsc_category_query; + $wpsc_category_query['subcategory_container'] = array('start_element' => $start_element, 'end_element' => $end_element); + echo "[wpsc_subcategory]"; +} +function wpsc_print_category_classes_section(){ + echo "[wpsc_category_classes]"; +} + +/** +* wpsc print category image function +* places the shortcode for the category image, accepts parameters for width and height +* @param integer width +* @param integer height +*/ +function wpsc_print_category_image($width = null, $height = null) { + global $wpsc_category_query; + $wpsc_category_query['image_size'] = array('width' => $width, 'height' => $height); + echo "[wpsc_category_image]"; +} + +/** +* wpsc print category products count function +* places the shortcode for the category product count, accepts parameters for the container element +* @param string starting HTML element +* @param string ending HTML element +*/ +function wpsc_print_category_products_count($start_element = '', $end_element = '') { + global $wpsc_category_query; + $wpsc_category_query['products_count'] = array('start_element' => $start_element, 'end_element' => $end_element); + echo "[wpsc_category_products_count]"; +} + +/** +* wpsc end category query function +*/ +function wpsc_end_category_query() { + global $wpdb, $wpsc_category_query; + $category_html = ob_get_clean(); + echo wpsc_display_category_loop($wpsc_category_query, $category_html); + unset($GLOBALS['wpsc_category_query']); +} + +/** +* wpsc category loop function +* This function recursively loops through the categories to display the category tree. +* This function also generates a tree of categories at the same time +* WARNING: as this function is recursive, be careful what you do with it. +* @param array the category query +* @param string the category html +* @param array the category array branch, is an internal value, leave it alone. +* @return string - the finished category html +*/ +function wpsc_display_category_loop($query, $category_html, &$category_branch = null){ + static $category_count_data = array(); // the array tree is stored in this + + if( isset($query['parent_category_id']) ) + $category_id = absint($query['parent_category_id']); + else + $category_id = 0; + $category_data = get_terms('wpsc_product_category','hide_empty=0&parent='.$category_id, OBJECT, 'display'); + $output =''; + + // if the category branch is identical to null, make it a reference to $category_count_data + if($category_branch === null) { + $category_branch =& $category_count_data; + } + $allowed_tags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array(), 'b'=> array()); + + $allowedtags = apply_filters('wpsc_category_description_allowed_tags' , $allowed_tags); + + foreach((array)$category_data as $category_row) { + + // modifys the query for the next round + $modified_query = $query; + $modified_query['parent_category_id'] = $category_row->term_id; + + // gets the count of products associated with this category + $category_count = $category_row->count; + + + // Sticks the category description in + $category_description = ''; + if($category_row->description != '' && ! empty( $query['description_container'] ) ) { + $start_element = $query['description_container']['start_element']; + $end_element = $query['description_container']['end_element']; + $category_description = $start_element.wpautop(wptexturize( wp_kses( $category_row->description, $allowedtags ))).$end_element; + } + + + // Creates the list of classes on the category item + $category_classes = wpsc_print_category_classes((array)$category_row, false); + + // Set the variables for this category + $category_branch[$category_row->term_id]['children'] = array(); + $category_branch[$category_row->term_id]['count'] = (int)$category_count; + + + // Recurse into the next level of categories + $sub_categories = wpsc_display_category_loop($modified_query, $category_html, $category_branch[$category_row->term_id]['children']); + + // grab the product count from the subcategories + foreach((array)$category_branch[$category_row->term_id]['children'] as $child_category) { + $category_branch[$category_row->term_id]['count'] += (int)$child_category['count']; + } + + // stick the category count array together here + // this must run after the subcategories and the count of products belonging to them has been obtained + + $category_count = $category_branch[$category_row->term_id]['count']; + + $start_element = ''; + $end_element = ''; + + if (isset($query['products_count']['start_element'])) { + $start_element = $query['products_count']['start_element']; + } + + if (isset($query['products_count']['end_element'])) { + $end_element = $query['products_count']['end_element']; + } + + $category_count_html = $start_element.$category_count.$end_element; + + + if ( isset( $query['subcategory_container'] ) && ! empty( $sub_categories ) ) { + $start_element = $query['subcategory_container']['start_element']; + $end_element = $query['subcategory_container']['end_element']; + $sub_categories = $start_element.$sub_categories.$end_element; + } + + // get the category images + $category_image = wpsc_place_category_image($category_row->term_id, $modified_query); + + if ( empty( $query['image_size']['width'] ) ) { + if ( ! wpsc_category_grid_view() ) + $width = wpsc_get_categorymeta( $category_row->term_id, 'image_width' ); + if ( empty( $width ) ) + $width = get_option( 'category_image_width' ); + } else { + $width = $query['image_size']['width']; + } + + if ( empty( $query['image_size']['height'] ) ) { + if ( ! wpsc_category_grid_view() ) + $height = wpsc_get_categorymeta( $category_row->term_id, 'image_height' ); + if ( empty( $height ) ) + $height = get_option( 'category_image_height' ); + } else { + $height = $query['image_size']['height']; + } + + $category_image = wpsc_get_categorymeta($category_row->term_id, 'image'); + $category_image_html = ''; + if(($query['show_thumbnails'] == 1)) { + if((!empty($category_image)) && is_file(WPSC_CATEGORY_DIR.$category_image)) { + $category_image_html = "{$category_row->name}"; + } elseif( isset( $query['show_name'] ) && 1 == $query['show_name']) { + $category_image_html .= "\n\r"; + $category_image_html .= " \n\r"; + $category_image_html .= " ".__('N/A','wp-e-commerce')."\n\r"; + $category_image_html .= " \n\r"; + $category_image_html .= "\n\r"; + } + + } + + + // get the list of products associated with this category. + $tags_to_replace = array('[wpsc_category_name]', + '[wpsc_category_description]', + '[wpsc_category_url]', + '[wpsc_category_id]', + '[wpsc_category_classes]', + '[wpsc_category_image]', + '[wpsc_subcategory]', + '[wpsc_category_products_count]'); + + $content_to_place = array( + esc_html($category_row->name), + $category_description, + esc_url( get_term_link( $category_row->slug, 'wpsc_product_category' ) ), + $category_row->term_id, + $category_classes, + $category_image_html, + $sub_categories, + $category_count_html); + + // Stick all the category html together and concatenate it to the previously generated HTML + $output .= str_replace($tags_to_replace, $content_to_place ,$category_html); + } + return $output; +} + +/** +* wpsc category image function +* if no parameters are passed, the category is not resized, otherwise it is resized to the specified dimensions +* @param integer category id +* @param array category query array +* @return string - the category image URL, or the URL of the resized version +*/ +function wpsc_place_category_image($category_id, $query) { + // show the full sized image for the product, if supplied with dimensions, will resize image to those. + $width = (isset($query['image_size']['width'])) ? ($query['image_size']['width']) : get_option('category_image_width'); + $height = (isset($query['image_size']['height'])) ? ($query['image_size']['height']) : get_option('category_image_height'); + $image_url = "index.php?wpsc_request_image=true&category_id=".$category_id."&width=".$width."&height=".$height; + return htmlspecialchars($image_url); +} + +/// category template tags end here + +/** +* wpsc_category_url function, makes permalink to the category or +* @param integer category ID, can be 0 +* @param boolean permalink compatibility, adds a prefix to prevent permalink namespace conflicts +*/ +function wpsc_category_url($category_id, $permalink_compatibility = false) { + return get_term_link( $category_id, 'wpsc_product_category'); +} + + +/** + * Returns true if you're on a category that is a WPeC category + * + * @uses is_tax() Returns true/false given taxonomy and takes second parameter of term + * @param string|array|int $term optional The term you could be checking for + * @return bool True if you are on a wpsc_product_category false if not + */ +function wpsc_is_in_category( $term = '' ) { + + return is_tax( 'wpsc_product_category', $term ); + +} + + +/** + * Uses a category's, (in the wpsc_product_category taxonomy), slug to find its + * ID, then returns it. + * + * @param string $category_slug The slug of the category who's ID we want. + * @return (int | bool) Returns the integer ID of the category if found, or a + * boolean false if the category is not found. + * + * @todo Cache the results of this somewhere. It could save quite a few trips + * to the MySQL server. + * + */ +function wpsc_category_id($category_slug = '') { + if(empty($category_slug)) + $category_slug = get_query_var( 'wpsc_product_category' ); + elseif(array_key_exists('wpsc_product_category', $_GET)) + $category_slug = $_GET['wpsc_product_category']; + + if(!empty($category_slug)) { + $category = get_term_by('slug', $category_slug, 'wpsc_product_category'); + if(!empty($category->term_id)){ + return $category->term_id; + } else { + return false; + } + } else { + return false; + } +} + +/** +* wpsc_category_description function, Gets the category description +* @param integer category ID, can be 0 +* @return string category description +*/ +function wpsc_category_description($category_id = null) { + if($category_id < 1) + $category_id = wpsc_category_id(); + $category = get_term_by( 'id', $category_id, 'wpsc_product_category' ); + return $category ? $category->description : ''; +} + +function wpsc_category_name($category_id = null) { + if ( $category_id < 1 ) + $category_id = wpsc_category_id(); + + $category = get_term_by( 'id', $category_id, 'wpsc_product_category' ); + return $category ? $category->name : ''; +} + +function nzshpcrt_display_categories_groups() { + return ''; +} + +/** wpsc list subcategories function + used to get an array of all the subcategories of a category. +*/ +function wpsc_list_subcategories($category_id = null) { + global $wpdb,$category_data; + + $category_list = $wpdb->get_col( $wpdb->prepare( "SELECT `id` FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `category_parent` = %d", $category_id ) ); + + if($category_list != null) { + foreach($category_list as $subcategory_id) { + $category_list = array_merge((array)$category_list, (array)wpsc_list_subcategories($subcategory_id)); + } + } + return $category_list; +} + +/** + * wpsc_show_category_thumbnails function + * @return bool - whether to show category thumbnails or not + */ +function wpsc_show_category_thumbnails(){ + if(get_option('show_category_thumbnails') && wpsc_category_image()) + return true; + else + return false; +} + +/** + * wpsc_show_category_description function + * @return bool - whether to show category description or not + */ +function wpsc_show_category_description(){ + return get_option( 'wpsc_category_description' ); +} + +/** + * wpsc buy now button code products function + * Sorry about the ugly code, this is just to get the functionality back, buy now will soon be overhauled, and this function will then be completely different + * @return string - html displaying one or more products + */ +function wpsc_buy_now_button( $product_id, $replaced_shortcode = false ) { + + $product_id = absint( $product_id ); + + $product = get_post( $product_id ); + $supported_gateways = array( 'wpsc_merchant_paypal_standard', 'paypal_multiple' ); + $selected_gateways = get_option( 'custom_gateway_options' ); + + if ( $replaced_shortcode ) { + ob_start(); + } + + if ( in_array( 'wpsc_merchant_paypal_standard', (array) $selected_gateways ) ) { + if ( $product_id > 0 ) { + + $post_meta = get_post_meta( $product_id, '_wpsc_product_metadata', true ); + $shipping = isset( $post_meta['shipping'] ) ? $post_meta['shipping']['local'] : ''; + $price = get_post_meta( $product_id, '_wpsc_price', true ); + $special_price = get_post_meta( $product_id, '_wpsc_special_price', true ); + + if ( $special_price ) + $price = $special_price; + + if ( wpsc_uses_shipping ( ) ) { + $handling = get_option( 'base_local_shipping' ); + } else { + $handling = $shipping; + } + + $has_variants = wpsc_product_has_variations( $product_id ) || ! wpsc_product_has_stock( $product_id ); + + $src = apply_filters( 'wpsc_buy_now_button_src', _x( 'https://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif', 'PayPal Buy Now Button', 'wp-e-commerce' ) ); + $classes = apply_filters( 'wpsc_buy_now_button_class', "wpsc-buy-now-form wpsc-buy-now-form-{$product_id}" ); + + $classes_array = array_map( 'sanitize_html_class', explode( ' ', $classes ) ); + + $classes = implode( ' ', $classes_array ); + + $button_html = sprintf( '', + disabled( $has_variants, true, false ), + esc_attr( $product_id ), + esc_url( $src ), + esc_attr__( 'PayPal - The safer, easier way to pay online', 'wp-e-commerce' ) + ); + + $button_html = apply_filters( 'wpsc_buy_now_button_html', $button_html, $product_id ); +?> +
+ + +', wpsc_vargrp_id(), wpsc_vargrp_form_id() ); + endwhile; + endif; /* END wpsc_product_has_variations */ +?> + + +
+ + + + + ' /> +
+ get_results( $wpdb->prepare( "SELECT `" . $wpdb->posts . "`.* FROM `" . WPSC_TABLE_ALSO_BOUGHT . "`, `" . $wpdb->posts . "` WHERE `selected_product`= %d AND `" . WPSC_TABLE_ALSO_BOUGHT . "`.`associated_product` = `" . $wpdb->posts . "`.`id` AND `" . $wpdb->posts . "`.`post_status` IN('publish','protected') ORDER BY `" . WPSC_TABLE_ALSO_BOUGHT . "`.`quantity` DESC LIMIT $also_bought_limit", $product_id ), ARRAY_A ); + if ( is_array( $also_bought ) && count( $also_bought ) > 0 ) { + $output .= '

' . __( 'People who bought this item also bought', 'wp-e-commerce' ) . '

'; + $output .= '
'; + foreach ( $also_bought as $also_bought_data ) { + $output .= '
'; + if ( get_option( 'show_thumbnails' ) == 1 ) { + $image_path = wpsc_the_product_thumbnail( $image_display_width, $image_display_height, $also_bought_data['ID'] ); + if ( $image_path ) { + $output .= ''; + $output .= ''; + $output .= ''; + } else { + if ( get_option( 'product_image_width' ) != '' ) { + $width_and_height = 'width="' . $image_display_height . '" height="' . $image_display_height . '" '; + } else { + $width_and_height = ''; + } + $output .= '' . esc_attr( get_the_title( $also_bought_data['ID'] ) ) . ''; + } + } + + $output .= '' . get_the_title( $also_bought_data['ID'] ) . ''; + if ( ! wpsc_product_is_donation( $also_bought_data['ID'] ) ) { + // Ideally use the wpsc_the_product_price_display() function here but needs some tweaking + $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 .= '' . wpsc_currency_display( $price ) . ''; + $output .= wpsc_currency_display( $special_price ); + } else { + $output .= wpsc_currency_display( $price ); + } + } + $output .= '
'; + } + $output .= '
'; + $output .= '
'; + } + return $output; +} + +/** + * Get the URL of the loading animation image. + * Can be filtered using the wpsc_loading_animation_url filter. + */ +function wpsc_loading_animation_url() { + return apply_filters( 'wpsc_loading_animation_url', WPSC_CORE_THEME_URL . 'wpsc-images/indicator.gif' ); +} + +/* + * wpsc product url function, gets the URL of a product, + * Deprecated, all parameters past the first unused. use get_permalink + */ + +function wpsc_product_url( $product_id, $category_id = null, $escape = true ) { + $post = get_post($product_id); + if ( isset($post->post_parent) && $post->post_parent > 0) { + return get_permalink($post->post_parent); + } else { + return get_permalink($product_id); + } +} + +function external_link( $product_id ) { + $link = get_product_meta( $product_id, 'external_link', true ); + if ( !stristr( $link, 'http://' ) ) { + $link = 'http://' . $link; + } + $target = wpsc_product_external_link_target( $product_id ); + $output .= ""; + return $output; +} + +/** + * wpsc_refresh_page_urls + * + * Refresh page urls when pages are updated + * + * @param int $post_id + * @param object $post + * @uses wpsc_update_permalink_slugs() + * @return int $post_id + */ +function wpsc_refresh_page_urls( $post_id, $post ) { + + if ( ! current_user_can( 'manage_options' ) ) + return; + + if ( 'page' != $post->post_type ) + return; + + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) + return; + + if ( ! in_array( $post->post_status, array( 'publish', 'private' ) ) ) + return; + + wpsc_update_permalink_slugs(); + + return $post_id; +} + +function wpsc_replace_wp_title( $input ) { + global $wpdb, $wp_query; + $output = wpsc_obtain_the_title(); + if ( $output != null ) { + return $output; + } + return $input; +} + +function wpsc_replace_bloginfo_title( $input, $show ) { + global $wpdb, $wp_query; + if ( $show == 'description' ) { + $output = wpsc_obtain_the_title(); + if ( $output != null ) { + return $output; + } + } + return $input; +} + From e26aecd5724187a146f1c40fa904f6e051307350 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 18 Feb 2021 14:38:28 +0000 Subject: [PATCH 13/17] Revert "Delete specials_widget.php" This reverts commit cb452476a1df8e95e990e4eaf939292f509a868b. --- .../widgets/specials_widget.php | 251 ++++++++++++++++++ 1 file changed, 251 insertions(+) create mode 100755 wpsc-components/theme-engine-v1/widgets/specials_widget.php diff --git a/wpsc-components/theme-engine-v1/widgets/specials_widget.php b/wpsc-components/theme-engine-v1/widgets/specials_widget.php new file mode 100755 index 0000000000..4faaa00ffa --- /dev/null +++ b/wpsc-components/theme-engine-v1/widgets/specials_widget.php @@ -0,0 +1,251 @@ + 'widget_wpsc_product_specials', + 'description' => __( 'Product Specials Widget', 'wp-e-commerce' ) + ); + + parent::__construct( 'wpsc_product_specials', __( '(WPEC) Product Specials', 'wp-e-commerce' ), $widget_ops ); + + } + + /** + * Widget Output + * + * @param $args (array) + * @param $instance (array) Widget values. + * + * @todo Add individual capability checks for each menu item rather than just manage_options. + */ + public function widget( $args, $instance ) { + + global $wpdb, $table_prefix; + + extract( $args ); + + echo $before_widget; + $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Product Specials', 'wp-e-commerce' ) : $instance['title'] ); + if ( $title ) + echo $before_title . $title . $after_title; + + wpsc_specials( $args, $instance ); + echo $after_widget; + + } + + /** + * Update Widget + * + * @param $new_instance (array) New widget values. + * @param $old_instance (array) Old widget values. + * + * @return (array) New values. + */ + public function update( $new_instance, $old_instance ) { + + $instance = $old_instance; + $instance['title'] = strip_tags( $new_instance['title'] ); + $instance['number'] = (int) $new_instance['number']; + $instance['show_thumbnails'] = (bool) $new_instance['show_thumbnails']; + $instance['show_description'] = (bool) $new_instance['show_description']; + $instance['show_old_price'] = (bool) $new_instance['show_old_price']; + $instance['show_discount'] = (bool) $new_instance['show_discount']; + + return $instance; + + } + + /** + * Widget Options Form + * + * @param $instance (array) Widget values. + */ + public function form( $instance ) { + + global $wpdb; + + // Defaults + $instance = wp_parse_args( (array) $instance, array( + 'title' => '', + 'show_description' => false, + 'show_thumbnails' => false, + 'number' => 5, + 'show_old_price' => false, + 'show_discount' => false, + ) ); + + // Values + $title = esc_attr( $instance['title'] ); + $number = (int) $instance['number']; + $show_thumbnails = (bool) $instance['show_thumbnails']; + $show_description = (bool) $instance['show_description']; + $show_discount = (bool) $instance['show_discount']; + $show_old_price = (bool) $instance['show_old_price']; + + ?> +

+ + +

+

+ + +

+

+ > +
+ > +
+ > +
+ > + +

+posts} AS p + INNER JOIN {$wpdb->postmeta} AS pm + ON p.ID = pm.post_id AND pm.meta_key = '_wpsc_special_price' AND pm.meta_value > 0 + WHERE p.post_parent != 0 AND p.post_status IN ('publish', 'inherit') + "; + + $parent_ids = $wpdb->get_col( $sql ); + + if ( $parent_ids ) { + $parent_ids = array_map( 'absint', $parent_ids ); + $where .= " AND ({$wpdb->posts}.ID IN (" . implode( ', ', $parent_ids ) . ") OR pm.meta_value > 0) "; + } else { + $where .= " AND pm.meta_value > 0 "; + } + + return $where; +} + +function _wpsc_filter_special_widget_join( $join ) { + global $wpdb; + $join .= " INNER JOIN {$wpdb->postmeta} AS pm ON {$wpdb->posts}.ID = pm.post_id AND pm.meta_key = '_wpsc_special_price' "; + return $join; +} + +/** + * Product Specials Widget content function + * + * Displays the latest products. + * + * Changes made in 3.8 that may affect users: + * + * 1. The product title link text does now not have a bold tag, it should be styled via css. + * 2.
tags have been ommitted. Padding and margins should be applied via css. + * 3. Each product is enclosed in a
with a 'wpec-special-product' class. + * 4. The product list is enclosed in a
with a 'wpec-special-products' class. + * 5. Function now expect a single paramter with an array of options (used to be a string which prepended the output). + */ + +<<<<<<< HEAD +function wpsc_specials( $args, $instance ) { +======= +function wpsc_specials( $args = null, $instance ) { +>>>>>>> parent of eb244fad (PHP 8 Compatibility) + + global $wpdb; + + $args = wp_parse_args( (array) $args, array( 'number' => 5 ) ); + + if ( ! $number = (int) $instance['number'] ) + $number = 5; + + $show_thumbnails = isset( $instance['show_thumbnails'] ) ? (bool) $instance['show_thumbnails'] : false; + $show_description = isset( $instance['show_description'] ) ? (bool) $instance['show_description'] : false; + $show_discount = isset( $instance['show_discount'] ) ? (bool) $instance['show_discount'] : false; + $show_old_price = isset( $instance['show_old_price'] ) ? (bool) $instance['show_old_price'] : false; + + $args = array( + 'post_type' => 'wpsc-product', + 'ignore_sticky_posts' => 1, + 'post_status' => 'publish', + 'post_parent' => 0, + 'posts_per_page' => $number, + 'no_found_rows' => true, + ); + + add_filter( 'posts_join', '_wpsc_filter_special_widget_join' ); + add_filter( 'posts_where', '_wpsc_filter_special_widget_where' ); + $special_products = new WP_Query( $args ); + remove_filter( 'posts_join', '_wpsc_filter_special_widget_join' ); + remove_filter( 'posts_where', '_wpsc_filter_special_widget_where' ); + + if ( ! $special_products->post_count ) { + echo apply_filters( 'wpsc_specials_widget_no_items_message', __( 'We currently have no items on special.', 'wp-e-commerce' ) ); + return; + } + + $product_ids = array(); + + while ( $special_products->have_posts() ) : + $special_products->the_post(); + ?> +

+ + +
+ +
+ + " href=""><?php echo esc_attr( wpsc_the_product_title() ); ?> + + <?php echo esc_attr( wpsc_the_product_title() ); ?> + +
+ +
+ $show_old_price, + 'output_you_save' => $show_discount, + ) + ); + ?> +

+ Date: Thu, 18 Feb 2021 14:38:34 +0000 Subject: [PATCH 14/17] Revert "Delete meta.functions.php" This reverts commit ab4ae6045f8c010240ad5f3971af0ab1023195ff. --- wpsc-includes/meta.functions.php | 387 +++++++++++++++++++++++++++++++ 1 file changed, 387 insertions(+) create mode 100755 wpsc-includes/meta.functions.php diff --git a/wpsc-includes/meta.functions.php b/wpsc-includes/meta.functions.php new file mode 100755 index 0000000000..6255c0e254 --- /dev/null +++ b/wpsc-includes/meta.functions.php @@ -0,0 +1,387 @@ +>>>>>> parent of eb244fad (PHP 8 Compatibility) + + global $wpdb; + + $cache_object_id = $object_id = (int) $object_id; + $meta_key = wpsc_sanitize_meta_key( $meta_key ); + + $meta_tuple = compact( 'object_type', 'object_id', 'meta_key' ); + $meta_tuple = apply_filters( 'wpsc_get_meta', $meta_tuple ); + + // Get cached meta + $meta_value = wp_cache_get( $cache_object_id, $meta_tuple['object_type'] ); + + // If not cached, get and cache all object meta + if ( $meta_value === false ) { + $meta_values = wpsc_update_meta_cache( $meta_tuple['object_type'], $meta_tuple['object_id'] ); + $meta_value = $meta_values[ $meta_tuple['object_id'] ]; + } + + if ( isset( $meta_value[ $meta_tuple['meta_key'] ] ) ) { + return maybe_unserialize( $meta_value[ $meta_tuple['meta_key'] ] ); + } + + return ''; + +} + +/** + * Adds and updates meta data in the database + * + * @internal + * + * @param integer $object_id Object ID. + * @param string $meta_key Meta key. + * @param mixed $meta_value Meta value. + * @param string $object_type Object type. + * @param boolean $global ? + * @return boolean + */ +function wpsc_update_meta( $object_id = 0, $meta_key, $meta_value, $object_type, $global = false ) { + + global $wpdb; + + if ( ! is_numeric( $object_id ) || empty( $object_id ) && ! $global ) { + return false; + } + + $cache_object_id = $object_id = (int) $object_id; + $meta_key = wpsc_sanitize_meta_key( $meta_key ); + + $meta_tuple = compact( 'object_type', 'object_id', 'meta_key', 'meta_value' ); + $meta_tuple = apply_filters( 'wpsc_update_meta', $meta_tuple ); + + $meta_value = $_meta_value = maybe_serialize( $meta_tuple['meta_value'] ); + $meta_value = maybe_unserialize( $meta_value ); + + $cur = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_META . "` WHERE `object_type` = %s AND `object_id` = %d AND `meta_key` = %s", $meta_tuple['object_type'], $meta_tuple['object_id'], $meta_tuple['meta_key'] ) ); + + if ( ! $cur ) { + $wpdb->insert( WPSC_TABLE_META, array( 'object_type' => $meta_tuple['object_type'], 'object_id' => $meta_tuple['object_id'], 'meta_key' => $meta_tuple['meta_key'], 'meta_value' => $_meta_value ) ); + } elseif ( $cur->meta_value != $meta_value ) { + $wpdb->update( WPSC_TABLE_META, array( 'meta_value' => $_meta_value ), array( 'object_type' => $meta_tuple['object_type'], 'object_id' => $meta_tuple['object_id'], 'meta_key' => $meta_tuple['meta_key'] ) ); + } + + wp_cache_delete( $cache_object_id, $meta_tuple['object_type'] ); + + if ( ! $cur ) { + return true; + } + +} + +/** + * Deletes meta data from the database + * + * @internal + * + * @param integer $object_id Object ID. + * @param string $meta_key Meta key. + * @param mixed $meta_value Meta value. + * @param string $object_type Object type. + * @param boolean $global ? + * @return boolean + */ +function wpsc_delete_meta( $object_id = 0, $meta_key, $meta_value, $object_type, $global = false ) { + + global $wpdb; + + if ( ! is_numeric( $object_id ) || empty( $object_id ) && ! $global ) { + return false; + } + + $cache_object_id = $object_id = (int) $object_id; + $meta_key = wpsc_sanitize_meta_key( $meta_key ); + + $meta_tuple = compact( 'object_type', 'object_id', 'meta_key', 'meta_value' ); + $meta_tuple = apply_filters( 'wpsc_delete_meta', $meta_tuple ); + + $meta_value = maybe_serialize( $meta_tuple['meta_value'] ); + + if ( empty( $meta_value ) ) { + $meta_sql = $wpdb->prepare( "SELECT `meta_id` FROM `" . WPSC_TABLE_META . "` WHERE `object_type` = %s AND `object_id` = %d AND `meta_key` = %s", $meta_tuple['object_type'], $meta_tuple['object_id'], $meta_tuple['meta_key'] ); + } else { + $meta_sql = $wpdb->prepare( "SELECT `meta_id` FROM `" . WPSC_TABLE_META . "` WHERE `object_type` = %s AND `object_id` = %d AND `meta_key` = %s AND `meta_value` = %s", $meta_tuple['object_type'], $meta_tuple['object_id'], $meta_tuple['meta_key'], $meta_value ); + } + + if ( ! $meta_id = $wpdb->get_var( $meta_sql ) ) { + return false; + } + $wpdb->query( $wpdb->prepare( "DELETE FROM `" . WPSC_TABLE_META . "` WHERE `meta_id` = %d", $meta_id ) ); + + wp_cache_delete( $cache_object_id, $meta_tuple['object_type'] ); + + return true; + +} + +/** + * Update Meta Cache + * + * Query database to get meta for objects, update the cache and return the object meta. + * + * @param string $object_type Object type. + * @param int|array $object_ids Object ID or IDs. + * @return array Array of objects and cached values. + */ +function wpsc_update_meta_cache( $object_type, $object_ids ) { + + global $wpdb; + + if ( ! $object_type || ! $object_ids ) { + return false; + } + + // If $object_ids is a string, convert to array + if ( ! is_array( $object_ids ) ) { + $object_ids = preg_replace( '|[^0-9,]|', '', $object_ids ); + $object_ids = explode( ',', $object_ids ); + } + + $object_ids = array_map( 'intval', $object_ids ); + + $ids = array(); + $cache = array(); + + // Only need to retrieve objects that aren't already cached + foreach ( $object_ids as $id ) { + $cached_object = wp_cache_get( $id, $object_type ); + if ( false === $cached_object ) { + $ids[] = $id; + } else { + $cache[ $id ] = $cached_object; + } + } + + if ( empty( $ids ) ) { + return $cache; + } + + $id_list = join( ',', $ids ); + $meta_list = $wpdb->get_results( $wpdb->prepare( "SELECT object_id, meta_key, meta_value FROM " . WPSC_TABLE_META . " WHERE `object_type` = '%s' AND `object_id` IN ( " . $id_list . " )", $object_type ), ARRAY_A ); + + // Add results to cache array + if ( ! empty( $meta_list ) ) { + foreach ( $meta_list as $metarow ) { + $mpid = intval( $metarow[ 'object_id' ] ); + $mkey = $metarow['meta_key']; + $mval = $metarow['meta_value']; + + // Add a value to the current pid/key: + $cache[ $mpid ][ $mkey ] = $mval; + } + } + + // Update cache + foreach ( $ids as $id ) { + if ( ! isset( $cache[ $id ] ) ) { + $cache[ $id ] = array(); + } + wp_cache_add( $id, $cache[ $id ], $object_type ); + } + + return $cache; +} + +/** + * category meta functions are as follows: + */ + +/** + * Retrieve meta field for a category + * + * @param int $cat_id Category ID. + * @param string $meta_key The meta key to retrieve. + * @return mixed Will be value of meta data field + */ +function wpsc_get_categorymeta( $cat_id, $meta_key ) { + return wpsc_get_meta( $cat_id, $meta_key, 'wpsc_category' ); +} + +/** + * Update meta field for a category + * + * @param int $cat_id Category ID. + * @param string $meta_key The meta key to retrieve. + * @param string $meta_value The value to be stored. + * @return mixed True if updated + */ +function wpsc_update_categorymeta( $cat_id, $meta_key, $meta_value ) { + return wpsc_update_meta( $cat_id, $meta_key, $meta_value, 'wpsc_category' ); +} + +/** + * Delete meta field for a category + * + * @param int $cat_id Category ID. + * @param string $meta_key The meta key to retrieve. + * @param string $meta_value Value to be compared before deleting. + * @return mixed True if updated + */ +function wpsc_delete_categorymeta( $cat_id, $meta_key, $meta_value = '' ) { + return wpsc_delete_meta( $cat_id, $meta_key, $meta_value, 'wpsc_category' ); +} +/** + * category meta functions end here. + */ + + +/** + * product meta functions start here + * all these functions just prefix the key with the meta prefix, and pass the values through to the equivalent post meta function. + */ + +/** + * add_product_meta function. + * + * @access public + * @param int $product_id Unique product identifier + * @param string $key Metadata name. + * @param mixed $value Metadata value. Must be serializable if non-scalar. + * @param bool $unique - obsolete + * @param bool $custom - obsolete + * @return int|bool WordPress Meta ID on success, false on failure. + */ +function add_product_meta( $product_id, $key, $value, $unique = false, $custom = false ) { + $key = WPSC_META_PREFIX.$key; + return add_post_meta($product_id, $key, $value); +} + +/** + * delete_product_meta function. + * + * @access public + * @param int $product_id + * @param string $key + * @param mixed $value. Optional. Metadata value. Must be serializable if non-scalar. Default empty + * @return bool True on success, false on failure. + */ +function delete_product_meta($product_id, $key, $value = '') { + $key = WPSC_META_PREFIX.$key; + return delete_post_meta($product_id, $key, $value); +} + + +/** + * get_product_meta function. + * + * @access public + * @param int $product_id + * @param string $key + * @param bool $single Optional. Whether to return a single value. Default false. + * @return mixed Will be an array if $single is false. Will be value of meta data + * field if $single is true. + */ +function get_product_meta($product_id, $key, $single = false) { + $key = WPSC_META_PREFIX.$key; + return get_post_meta($product_id, $key, $single); +} + +/** + * update_product_meta function. + * + * @access public + * @param int $product_id + * @param string $key + * @param mixed Metadata value. Must be serializable if non-scalar. + * @param string Optional. Previous value to check before removing. + * Defaults to empty. (default: '') + * @return int|bool Meta ID if the key didn't exist, true on successful update, + * false on failure. + */ +function update_product_meta($product_id, $key, $value, $prev_value = '') { + $key = WPSC_META_PREFIX.$key; + return update_post_meta($product_id, $key, $value, $prev_value); +} + + +/** + * product meta functions end here + */ + +class wpsc_custom_meta { + // Custom meta values + var $custom_meta; + var $custom_meta_count = 0; + var $current_custom_meta = -1; + var $custom_meta_values; + + function __construct( $post_id ) { + + $cleaned_metas = array(); + + if ( ! empty( $post_id ) ) { + $meta_values = get_post_meta( $post_id ); + + foreach ( $meta_values as $key => $values ) { + if ( ! is_protected_meta( $key, 'wpsc-product' ) ) { + if ( is_array( $values ) ) { + foreach ( $values as $value ) { + $cleaned_metas[] = array( 'meta_key' => $key, 'meta_value' => $value ); + } + } + } + } + } + + $this->custom_meta = $cleaned_metas; + $this->custom_meta_count = count( $this->custom_meta ); + } + + function have_custom_meta() { + if (($this->current_custom_meta + 1) < $this->custom_meta_count) { + return true; + } else if ($this->current_custom_meta + 1 == $this->custom_meta_count && $this->custom_meta_count > 0) { + $this->rewind_custom_meta(); + } + return false; + } + + /* + * Custom Meta Loop Code Starts here + */ + function next_custom_meta() { + $this->current_custom_meta++; + $this->custom_meta_values = $this->custom_meta[$this->current_custom_meta]; + return $this->custom_meta_values; + } + + + function the_custom_meta() { + $this->custom_meta_values = $this->next_custom_meta(); + return $this->custom_meta_values; + } + + function rewind_custom_meta() { + if ($this->custom_meta_count > 0) { + $this->custom_meta_values = $this->custom_meta[0]; + } + } +} \ No newline at end of file From 3a21d2560069e6e8a1746cf656932dca77b62ecf Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 18 Feb 2021 14:38:49 +0000 Subject: [PATCH 15/17] Revert "Delete latest_product_widget.php" This reverts commit 79f4b33a8bf6019a6984a7db63ef0e160567a81f. --- .../widgets/latest_product_widget.php | 167 ++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100755 wpsc-components/theme-engine-v1/widgets/latest_product_widget.php diff --git a/wpsc-components/theme-engine-v1/widgets/latest_product_widget.php b/wpsc-components/theme-engine-v1/widgets/latest_product_widget.php new file mode 100755 index 0000000000..87b739f5d5 --- /dev/null +++ b/wpsc-components/theme-engine-v1/widgets/latest_product_widget.php @@ -0,0 +1,167 @@ + 'widget_wpsc_latest_products','description' => __( 'Latest Products Widget', 'wp-e-commerce' ) ); + parent::__construct( 'wpsc_latest_products', __( '(WPEC) Latest Products', 'wp-e-commerce' ), $widget_ops ); + } + + /** + * Widget Output + * + * @param $args (array) + * @param $instance (array) Widget values. + */ + function widget( $args, $instance ) { + + global $wpdb, $table_prefix; + + extract( $args ); + + $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Latest Products', 'wp-e-commerce' ) : $instance['title'] ); + + echo $before_widget; + + if ( $title ) + echo $before_title . $title . $after_title; + wpsc_latest_product( $args, $instance ); + echo $after_widget; + } + + /** + * Update Widget + * + * @param $new_instance (array) New widget values. + * @param $old_instance (array) Old widget values. + * + * @return (array) New values. + */ + function update( $new_instance, $old_instance ) { + + $instance = $old_instance; + $instance['title'] = strip_tags( $new_instance['title'] ); + $instance['number'] = (int)$new_instance['number']; + $instance['image'] = (bool)$new_instance['image']; + $instance['height'] = (int)$new_instance['height']; + $instance['width'] = (int)$new_instance['width']; + + return $instance; + + } + + /** + * Widget Options Form + * + * @param $instance (array) Widget values. + */ + function form( $instance ) { + + global $wpdb; + + // Defaults + $instance = wp_parse_args( (array)$instance, array( + 'title' => '', + 'number' => 5, + 'width' => 45, + 'height' => 45, + 'image' => false, + ) ); + + // Values + $title = esc_attr( $instance['title'] ); + $number = (int)$instance['number']; + $image = (bool)$instance['image']; + $width = (int) $instance['width']; + $height = (int) $instance['height']; ?> + +

+ + +

+ +

+ + +

+ +

+ onclick="jQuery('.wpsc_latest_image').toggle()"> + +

+ + + 5 ) ); + $options = get_option( 'wpsc-widget_latest_products' ); + $number = isset($instance['number']) ? (int)$instance['number'] : 5; + $image = isset($instance['image']) ? (bool)$instance['image'] : FALSE; + + if ( isset($instance['width'] ) ) + $width = $instance['width']; + + if ( isset( $instance['height'] ) ) + $height = $instance['height']; + + $latest_products = get_posts( array( + 'post_type' => 'wpsc-product', + 'numberposts' => $number, + 'orderby' => 'post_date', + 'post_parent' => 0, + 'post_status' => 'publish', + 'order' => 'DESC' + ) ); + $output = ''; + + if ( count( $latest_products ) > 0 ) { + $output .= '"; + } + echo $output; + } +?> From 2d07a1447de5b1417868eaed54ab7841cac193df Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 18 Feb 2021 14:38:57 +0000 Subject: [PATCH 16/17] Revert "Delete wpsc-deprecated.php" This reverts commit 5a02103f876470aab9b716f1bdca03b6314bd399. --- wpsc-core/wpsc-deprecated.php | 2407 +++++++++++++++++++++++++++++++++ 1 file changed, 2407 insertions(+) create mode 100644 wpsc-core/wpsc-deprecated.php diff --git a/wpsc-core/wpsc-deprecated.php b/wpsc-core/wpsc-deprecated.php new file mode 100644 index 0000000000..f64cf715c6 --- /dev/null +++ b/wpsc-core/wpsc-deprecated.php @@ -0,0 +1,2407 @@ + tags have been ommitted. Padding and margins should be applied via css. + * 3. Each product is enclosed in a
with a 'wpec-latest-product' class. + * 4. The product list is enclosed in a
with a 'wpec-latest-products' class. + * 5. Function now expects two arrays as per the standard Widget API. + */ +function nzshpcrt_latest_product( $args = null, $instance ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_latest_product'); + echo wpsc_latest_product( $args, $instance ); +} + +/** + * nzshpcrt_currency_display function. + * Obsolete, preserved for backwards compatibility + * + * @access public + * @param mixed $price_in + * @param mixed $tax_status + * @param bool $nohtml deprecated + * @param bool $id. deprecated + * @param bool $no_dollar_sign. (default: false) + * @return void + */ +function nzshpcrt_currency_display($price_in, $tax_status, $nohtml = false, $id = false, $no_dollar_sign = false) { + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + + $output = wpsc_currency_display($price_in, array( + 'display_currency_symbol' => !(bool)$no_dollar_sign, + 'display_as_html' => ! (bool)$nohtml, + 'display_decimal_point' => true, + 'display_currency_code' => false + )); + return $output; +} + +/** + * This should be deprecated using _wpsc_deprecated_function() however the + * constants are still being used in admin-legacy.js, which is still enqueued + * by default in wp-admin. + * + * @deprecated + */ +function wpsc_include_language_constants(){ + // _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + + if(!defined('TXT_WPSC_ABOUT_THIS_PAGE')) + include_once(WPSC_FILE_PATH.'/wpsc-languages/EN_en.php'); +} +add_action('init','wpsc_include_language_constants'); + +if(!function_exists('wpsc_has_noca_message')){ + function wpsc_has_noca_message(){ + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + if(isset($_SESSION['nocamsg']) && isset($_GET['noca']) && $_GET['noca'] == 'confirm') + return true; + else + return false; + } +} + +if(!function_exists('wpsc_is_noca_gateway')){ + function wpsc_is_noca_gateway(){ + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + if(count($wpsc_gateway->wpsc_gateways) == 1 && $wpsc_gateway->wpsc_gateways[0]['name'] == 'Noca') + return true; + else + return false; + } +} + +/** + * wpsc current_page + * @return (int) The current page number + */ +function wpsc_current_page() { + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + + global $wpsc_query; + + $current_page = 1; + + if ( $wpsc_query->query_vars['page'] > 1) { + $current_page = $wpsc_query->query_vars['page']; + } + + return $current_page; + +} + +/** + * wpsc showing products + * Displays the number of page showing in the form "10 to 20". + * If only on page is being display it will return the total amount of products showing. + * @return (string) Number of products showing + */ +function wpsc_showing_products() { + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + + global $wpsc_query; + + // If we are using pages... + if ( ( get_option( 'use_pagination' ) == 1 ) ) { + $products_per_page = $wpsc_query->query_vars['number_per_page']; + if ( $wpsc_query->query_vars['page'] > 0 ) { + $startnum = ( $wpsc_query->query_vars['page'] - 1 ) * $products_per_page; + } else { + $startnum = 0; + } + return ( $startnum + 1 ) . ' to ' . ( $startnum + wpsc_product_count() ); + } + + return wpsc_total_product_count(); + +} + +/** + * wpsc showing products page + * Displays the number of page showing in the form "5 of 10". + * @return (string) Number of pages showing. + */ +function wpsc_showing_products_page() { + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + + global $wpsc_query; + + $output = $wpsc_query->page_count; + $current_page = wpsc_current_page(); + + return $current_page . ' of ' . $output; + +} + + +/** + * is wpsc profile page + * Checks if the current account page tab is Edit Profile. + * @deprecated since 3.8.10 + * @return (boolean) true if current tab ID is edit_profile. + */ +function is_wpsc_profile_page() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.10' ); + return !empty($_REQUEST['tab']) && ( $_REQUEST['tab'] == 'edit_profile' ); +} + +/** + * is wpsc profile page + * Checks if the current account page tab is Downloads. + * @deprecated since 3.8.10 + * @return (boolean) true if current tab ID is downloads. + */ +function is_wpsc_downloads_page() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.10' ); + return !empty($_REQUEST['tab']) && ( $_REQUEST['tab'] == 'downloads' ); +} + + +/** + * wpsc user details + * Displays the Purchase History account page section. + * @deprecated since 3.8.10 + * @return (string) The Purchase History page template. + */ +function wpsc_user_details() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.10' ); + return wpsc_user_purchases(); +} + + +/** + * wpsc product search url + * Add product_search parameter if required. + * @param $url (string) URL. + * @return (string) URL. + */ +function wpsc_product_search_url( $url ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + if ( isset( $_GET['product_search'] ) ) { + if ( strrpos( $url, '?') ) { + $url .= '&product_search=' . $_GET['product_search']; + } else { + $url .= '?product_search=' . $_GET['product_search']; + } + } + + return $url; + +} + +/** + * wpsc adjacent products url + * URL for the next or previous page of products on a category or group page. + * @param $n (int) Page number. + * @return (string) URL for the adjacent products page link. + */ +function wpsc_adjacent_products_url( $n ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination'); + return false; + +} + +/** + * wpsc next products link + * Links to the next page of products on a category or group page. + * @param $text (string) Link text. + * @param $show_disabled (bool) Show unlinked text if last page. + * @return (string) Next page link or text. + */ +function wpsc_next_products_link( $text = 'Next', $show_disabled = false ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination'); + return false; +} + +/** + * wpsc previous products link + * Links to the previous page of products on a category or group page. + * @param $text (string) Link text. + * @param $show_disabled (bool) Show unlinked text if first page. + * @return (string) Previous page link or text. + */ +function wpsc_previous_products_link( $text = 'Previous', $show_disabled = false ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination'); + return false; +} + +/** + * wpsc first products link + * Links to the first page of products on a category or group page. + * @param $text (string) Link text. + * @param $show_disabled (bool) Show unlinked text if last page. + * @return (string) First page link or text. + */ +function wpsc_first_products_link( $text = 'First', $show_disabled = false ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination'); + return false; +} + +/** + * wpsc last products link + * Links to the last page of products on a category or group page. + * @param $text (string) Link text. + * @param $show_disabled (bool) Show unlinked text if first page. + * @return (string) Last page link or text. + */ +function wpsc_last_products_link( $text = 'Last', $show_disabled = false ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination'); + return false; + +} + +/** + * Saves the variation set data + * @param nothing + * @return nothing + */ +function wpsc_save_variation_set() { + _wpsc_deprecated_function( __FUNCTION__, '3.8'); + return false; +} + +/** + * wpsc have pages function + * @return boolean - true while we have pages to loop through + */ +function wpsc_have_pages() { + _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination'); + return false; +} + +/** + * wpsc the page function + * @return nothing - iterate through the pages + */ +function wpsc_the_page() { + _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination'); + return false; +} + +/** + * wpsc page number function + * @return integer - the page number + */ +function wpsc_page_number() { + _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_pagination'); + return false; +} + +function wpsc_ordersummary() { + _wpsc_deprecated_function( __FUNCTION__, '3.8'); + return false; +} + +function display_ecomm_rss_feed() { + _wpsc_deprecated_function( __FUNCTION__, '3.8'); + return false; +} + +function display_ecomm_admin_menu() { + _wpsc_deprecated_function( __FUNCTION__, '3.8'); + return false; +} + +// displays error messages if the category setup is odd in some way +// needs to be in a function because there are at least three places where this code must be used. +function wpsc_odd_category_setup() { + _wpsc_deprecated_function( __FUNCTION__, '3.8'); + return false; +} + +function wpsc_product_image_html( $image_name, $product_id ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8'); + return false; +} + +function wpsc_delete_currency_layer() { + _wpsc_deprecated_function( __FUNCTION__, '3.8'); + return false; +} + +function wpsc_akst_send_mail() { + _wpsc_deprecated_function( __FUNCTION__, '3.8'); + return false; +} + +function wpsc_akst_hide_pop() { + _wpsc_deprecated_function( __FUNCTION__, '3.8'); + return false; +} + +function wpsc_akst_page() { + _wpsc_deprecated_function( __FUNCTION__, '3.8'); + return false; +} + +function wpsc_akst_share_link($action = 'print') { + _wpsc_deprecated_function( __FUNCTION__, '3.8'); + if($action == 'print') + echo '
'; + else + return '
'; + return false; +} + +function wpsc_akst_share_form() { + _wpsc_deprecated_function( __FUNCTION__, '3.8'); + return false; +} + +function wpsc_has_shipping_form() { + _wpsc_deprecated_function( __FUNCTION__, '3.8'); + return false; +} + +/** + * wpsc_is_admin function. + * + * @access public + * @return void + * General use function for checking if user is on WPSC admin pages + */ + +function wpsc_is_admin() { + _wpsc_deprecated_function( __FUNCTION__, '3.8'); + global $pagenow; + + $current_screen = get_current_screen(); + + if( 'post.php' == $pagenow && 'wpsc-product' == $current_screen->post_type ) return true; + + return false; + +} + +/** + * used in legacy theme templates + * see http://plugins.svn.wordpress.org/wp-e-commerce/tags/3.7.8/themes/default/category_widget.php + * + * @return void + */ +function wpsc_print_product_list() { + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); +} + +/** + * count total products on a page + * see http://plugins.svn.wordpress.org/wp-e-commerce/tags/3.7.8/themes/iShop/products_page.php + * + * @return int + */ +function wpsc_total_product_count() { + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + return wpsc_product_count(); +} + +/** + * WPSC_Query() is deprecated in favor of WP_Query() + * Note that although we fall back to WP_Query() when WPSC_Query() is used, + * the results might not be what you expect. + * + */ +class WPSC_Query extends WP_Query { + public function __construct( $query = '' ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8', 'WP_Query()' ); + $query = wp_parse_args( $query ); + $query['post_type'] = 'wpsc-product'; + parent::WP_Query( $query ); + } +} + +function wpec_get_the_post_id_by_shortcode( $shortcode ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8.9', 'wpsc_get_the_post_id_by_shortcode' ); + return wpsc_get_the_post_id_by_shortcode( $shortcode ); +} + +/** + * wpsc_update_permalinks update the product pages permalinks when WordPress permalinks are changed + * + * @public + * + * @deprecated Use _wpsc_action_permalink_structure_changed() instead. + * @3.8 + * @returns nothing + */ +function wpsc_update_permalinks( $return = '' ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8.9', '_wpsc_action_permalink_structure_changed' ); + _wpsc_action_permalink_structure_changed(); +} + +/** + * @deprecated Use _wpsc_display_permalink_refresh_notice() instead; + */ +function wpsc_check_permalink_notice() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.9', '_wpsc_display_permalink_refresh_notice' ); + _wpsc_display_permalink_refresh_notice(); +} + +/** + * @deprecated since 3.8.8. Not used in core any more. + */ +function wpsc_display_tracking_id(){ + _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); + $value = wpsc_trackingid_value(); + if(!empty($value)) + return $value; + else + return __('Add New','wp-e-commerce'); +} + +/** + * @deprecated since 3.8.8. Not used in core any more. + */ +function wpsc_the_purch_item_price() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); + global $purchlogs; + if ( $purchlogs->purchitem->processed > 1 && $purchlogs->purchitem->processed != 6 ) { + $purchlogs->totalAmount += $purchlogs->purchitem->totalprice; + } + return $purchlogs->purchitem->totalprice; +} + +/** + * @deprecated since 3.8.8. Not used in core any more. + */ +function wpsc_the_purch_item_date() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); + global $purchlogs; + return date( 'M d Y,g:i a', $purchlogs->purchitem->date ); +} + +/** + * @deprecated since 3.8.8. Not used in core any more. + */ +function wpsc_the_purch_item_name() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); + global $purchlogs; + if ( wpsc_purchlogs_has_customfields( wpsc_the_purch_item_id() ) ) { + return $purchlogs->the_purch_item_name() . '' . esc_attr__( 'exclamation icon', 'wp-e-commerce' ) . ''; + } else { + return $purchlogs->the_purch_item_name(); + } +} + +/** + * @deprecated since 3.8.8. Not used in core any more. + */ +function wpsc_the_purch_item_id() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); + global $purchlogs; + return $purchlogs->purchitem->id; +} + +/** + * @deprecated since 3.8.8. Not used in core any more. + */ +function wpsc_the_purch_item_details() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); + global $purchlogs; + return $purchlogs->the_purch_item_details(); +} + +//status loop functions +/** + * status loop functions + * @deprecated since 3.8.8. Not used in core any more. + */ +function wpsc_have_purch_items_statuses() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); + global $purchlogs; + return $purchlogs->have_purch_status(); +} + +/** + * @deprecated since 3.8.8. Not used in core any more. + */ +function wpsc_the_purch_status() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); + global $purchlogs; + return $purchlogs->the_purch_status(); +} + +/** + * @deprecated since 3.8.8. Not used in core any more. + */ +function wpsc_purchlogs_is_google_checkout() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); + global $purchlogs; + if ( $purchlogs->purchitem->gateway == 'google' ) { + return true; + } else { + return false; + } +} + +/** + * @deprecated since 3.8.8. Not used in core any more. + */ +function wpsc_the_purch_total() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); + global $purchlogs; + return $purchlogs->totalAmount; +} + +/** + * @deprecated since 3.8.8. Not used in core any more. + */ +function wpsc_the_purch_item() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); + global $purchlogs; + if ( isset( $_SESSION['newlogs'] ) ) { + $purchlogs->allpurchaselogs = $_SESSION['newlogs']; + $purchlogs->purch_item_count = count( $_SESSION['newlogs'] ); + } + return $purchlogs->the_purch_item(); +} + +/** + * @deprecated since 3.8.8. Not used in core any more. + */ +function wpsc_the_purch_item_statuses() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); + global $purchlogs; + return $purchlogs->the_purch_item_statuses(); +} + +/** + * @deprecated since 3.8.8. Not used in core any more. + */ +function wpsc_the_purch_item_status() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); + global $purchlogs; + return $purchlogs->the_purch_item_status(); +} + +/** + * @deprecated since 3.8.8. Not used in core any more. + */ +function wpsc_the_purch_status_id() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); + global $purchlogs; + return $purchlogs->purchstatus['order']; +} + +/** + * @deprecated since 3.8.8. Not used in core any more. + */ +function wpsc_purchlog_filter_by() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); + wpsc_change_purchlog_view( $_POST['view_purchlogs_by'], $_POST['view_purchlogs_by_status'] ); +} + +/** + * @deprecated since 3.8.8. Not used in core any more. + */ +function wpsc_the_purch_status_name() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); + global $purchlogs; + if ( isset( $purchlogs->purchstatus['label'] ) ) { + return $purchlogs->purchstatus['label']; + } +} + +/** + * @deprecated since 3.8.8. Not used in core any more. + */ +function wpsc_purchlogs_getfirstdates() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); + global $purchlogs; + $dates = $purchlogs->getdates(); + $fDate = ''; + foreach ( $dates as $date ) { + $is_selected = ''; + $cleanDate = date( 'M Y', $date['start'] ); + $value = $date["start"] . "_" . $date["end"]; + if ( $value == $_GET['view_purchlogs_by'] ) { + $is_selected = 'selected="selected"'; + } + $fDate .= ""; + } + return $fDate; +} + +/** + * @deprecated since 3.8.8. Not used in core any more. + */ +function wpsc_change_purchlog_view( $viewby, $status='' ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); + global $purchlogs; + if ( $viewby == 'all' ) { + $dates = $purchlogs->getdates(); + $purchaselogs = $purchlogs->get_purchlogs( $dates, $status ); + $_SESSION['newlogs'] = $purchaselogs; + $purchlogs->allpurchaselogs = $purchaselogs; + } elseif ( $viewby == '3mnths' ) { + $dates = $purchlogs->getdates(); + $dates = array_slice( $dates, 0, 3 ); + $purchlogs->current_start_timestamp = $dates[count($dates)-1]['start']; + $purchlogs->current_end_timestamp = $dates[0]['end']; + $newlogs = $purchlogs->get_purchlogs( $dates, $status ); + $_SESSION['newlogs'] = $newlogs; + $purchlogs->allpurchaselogs = $newlogs; + } else { + + $dates = explode( '_', $viewby ); + $date[0]['start'] = $dates[0]; + $date[0]['end'] = $dates[1]; + $purchlogs->current_start_timestamp = $dates[0]; + $purchlogs->current_end_timestamp = $dates[1]; + $newlogs = $purchlogs->get_purchlogs( $date, $status ); + $_SESSION['newlogs'] = $newlogs; + $purchlogs->allpurchaselogs = $newlogs; + } +} + +/** + * @deprecated since 3.8.8. Not used in core any more. + */ +function wpsc_search_purchlog_view( $search ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); + global $purchlogs; + $newlogs = $purchlogs->search_purchlog_view( $search ); + $purchlogs->getDates(); + $purchlogs->purch_item_count = count( $newlogs ); + $purchlogs->allpurchaselogs = $newlogs; +} + +/** + * @deprecated since 3.8.8. Not used in core any more. + */ +function wpsc_purchlog_is_checked_status() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.8' ); + global $purchlogitem, $purchlogs; + + if ( $purchlogs->purchstatus['order'] == $purchlogitem->extrainfo->processed ) { + return 'selected="selected"'; + } else { + return ''; + } +} + +/** + * @deprecated since 3.8.9. Use _wpsc_country_dropdown_options instead. + * @param string $selected_country ISO code of selected country + * @return string output + */ +function country_list( $selected_country = null ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8.9', '_wpsc_country_dropdown_options' ); + return _wpsc_country_dropdown_options( array( 'selected' => $selected_country ) ); +} + +/** + * @deprecated since 3.8.9. Use wpsc_get_the_product_tags() instead. + * @param integer $id Product ID + * @return array Product tags + */ +function get_the_product_tags( $id = 0 ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8.9', 'wpsc_get_the_product_tags' ); + return wpsc_get_the_product_tags( $id ); +} + +/** + * wpsc_product_rows function, copies the functionality of the wordpress code for displaying posts and pages, but is for products + * + * @deprecated since 3.8.9 + */ +function wpsc_admin_product_listing( $parent_product = null, $args = array() ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8.9' ); + global $wp_query; + + if ( empty( $args ) ) + $args = $wp_query->query; + + add_filter( 'the_title','esc_html' ); + + $args = array_merge( $args, array( 'posts_per_page' => '-1' ) ); + + $GLOBALS['wpsc_products'] = get_posts( $args ); + + if ( ! $GLOBALS['wpsc_products'] ) : + + ?> + + + + + + + static $rowclass, $object_terms_cache = array(); + + // store terms associated with variants inside a cache array. This only requires 1 DB query. + if ( empty( $object_terms_cache ) ) { + $ids = wp_list_pluck( $wpsc_products, 'ID' ); + $object_terms = wp_get_object_terms( $ids, 'wpsc-variation', array( 'fields' => 'all_with_object_id' ) ); + foreach ( $object_terms as $term ) { + if ( ! array_key_exists( $term->object_id, $object_terms_cache ) ) + $object_terms_cache[$term->object_id] = array(); + + $object_terms_cache[$term->object_id][$term->parent] = $term->name; + } + } + + $global_product = $product; + setup_postdata($product); + $product_post_type_object = get_post_type_object('wpsc-product'); + $current_user_can_edit_this_product = current_user_can( $product_post_type_object->cap->edit_post, $product->ID ); + + $rowclass = 'alternate' == $rowclass ? '' : 'alternate'; + $post_owner = ( $current_user->ID == $product->post_author ? 'self' : 'other' ); + $edit_link = get_edit_post_link( $product->ID ); + + if ( isset( $object_terms_cache[$product->ID] ) ) { + ksort( $object_terms_cache[$product->ID] ); + $title = implode( ', ', $object_terms_cache[$product->ID] ); + } else { + $title = get_the_title( $product->ID ); + } + + if ( empty( $title ) ) + $title = __( '(no title)', 'wp-e-commerce' ); + + ?> + + post_status ); ?> iedit ' valign="top"> + '', 'title' => __('Name', 'wp-e-commerce') , 'weight' => __('Weight', 'wp-e-commerce'), 'stock' => __('Stock', 'wp-e-commerce'), 'price' => __('Price', 'wp-e-commerce'), 'sale_price' => __('Sale Price', 'wp-e-commerce'), 'SKU' => __('SKU', 'wp-e-commerce'), 'hidden_alerts' => ''); + + foreach ( $posts_columns as $column_name=>$column_display_name ) { + $attributes = "class=\"$column_name column-$column_name\""; + + switch ($column_name) { + + case 'date': /* !date case */ + if ( '0000-00-00 00:00:00' == $product->post_date && 'date' == $column_name ) { + $t_time = $h_time = __( 'Unpublished', 'wp-e-commerce' ); + $time_diff = 0; + } else { + $t_time = get_the_time( __( 'Y/m/d g:i:s A', 'wp-e-commerce' ) ); + $m_time = $product->post_date; + $time = get_post_time('G', true, $post); + + $time_diff = time() - $time; + + if ( $time_diff > 0 && $time_diff < 24*60*60 ) + $h_time = sprintf( __( '%s ago', 'wp-e-commerce' ), human_time_diff( $time ) ); + else + $h_time = mysql2date(__( 'Y/m/d', 'wp-e-commerce' ), $m_time); + } + + echo ''; + if ( 'excerpt' == $mode ) + echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode); + else + echo '' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . ''; + echo '
'; + if ( 'publish' == $product->post_status ) { + _e( 'Published', 'wp-e-commerce' ); + } elseif ( 'future' == $product->post_status ) { + if ( $time_diff > 0 ) + echo '' . __( 'Missed schedule', 'wp-e-commerce' ) . ''; + else + _e( 'Scheduled', 'wp-e-commerce' ); + } else { + _e( 'Last Modified', 'wp-e-commerce' ); + } + echo ''; + break; + + case 'title': /* !title case */ + $attributes = 'class="post-title column-title"'; + + $edit_link = wp_nonce_url( $edit_link, 'edit-product_'.$product->ID ); + ?> + > + + post_status != 'trash' ) { ?> + + + + + + + <?php echo $product_alert[' title='' class='product-alert-image' src='/product-alert.jpg' alt='' /> + + + ID)) + $has_var = 'wpsc_has_variation'; + $actions = array(); + if ( $current_user_can_edit_this_product && 'trash' != $product->post_status ) { + $actions['edit'] = ''. __( 'Edit', 'wp-e-commerce' ) . ''; + //commenting this out for now as we are trying new variation ui quick edit boxes are open by default so we dont need this link. + //$actions['quick_edit'] = "".__('Quick Edit', 'wp-e-commerce').""; + } + + $actions = apply_filters('post_row_actions', $actions, $product); + $action_count = count($actions); + $i = 0; + echo '
'; + + foreach ( $actions as $action => $link ) { + ++$i; + ( $i == $action_count ) ? $sep = '' : $sep = ' | '; + echo "$link$sep"; + } + + echo '
'; + ?> + + + + 'attachment', + 'numberposts' => 1, + 'post_status' => null, + 'post_parent' => $product->ID, + 'orderby' => 'menu_order', + 'order' => 'ASC' + ); + + if(isset($product->ID) && has_post_thumbnail($product->ID)){ + echo get_the_post_thumbnail($product->ID, 'admin-product-thumbnails'); + } else { + $image_url = WPSC_CORE_IMAGES_URL . "/no-image-uploaded.gif"; + ?> + ' src='' alt='' width='38' height='38' /> + + + ID, 'price', true); + ?> + > + + + + + ID, ''); + foreach($product_data['meta'] as $meta_name => $meta_value) { + $product_data['meta'][$meta_name] = maybe_unserialize(array_pop($meta_value)); + } + $product_data['transformed'] = array(); + if(!isset($product_data['meta']['_wpsc_product_metadata']['weight'])) $product_data['meta']['_wpsc_product_metadata']['weight'] = ""; + if(!isset($product_data['meta']['_wpsc_product_metadata']['weight_unit'])) $product_data['meta']['_wpsc_product_metadata']['weight_unit'] = ""; + + $product_data['transformed']['weight'] = wpsc_convert_weight($product_data['meta']['_wpsc_product_metadata']['weight'], "pound", $product_data['meta']['_wpsc_product_metadata']['weight_unit'], false); + $weight = $product_data['transformed']['weight']; + if($weight == ''){ + $weight = '0'; + } + ?> + > + + + + + ID, '_wpsc_stock', true); + ?> + > + + + + + + >ID); + if ( !empty( $categories ) ) { + $out = array(); + foreach ( $categories as $c ) + $out[] = " " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . ""; + echo join( ', ', $out ); + } else { + esc_html_e( 'Uncategorized', 'wp-e-commerce' ); + } + ?> + + >ID); + if ( !empty( $tags ) ) { + $out = array(); + foreach ( $tags as $c ) + $out[] = " " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . ""; + echo join( ', ', $out ); + } else { + esc_html_e( 'No Tags', 'wp-e-commerce' ); + } + ?> + ID, '_wpsc_sku', true); + ?> + > + + + +

+ + ID, '_wpsc_special_price', true); + ?> + > + + + + + >
+ '; + comments_number("" . /* translators: comment count link */ _x( '0', 'comment count', 'wp-e-commerce' ) . '', "" . /* translators: comment count link */ _x('1', 'comment count', 'wp-e-commerce') . '', "" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count', 'wp-e-commerce') . ''); + if ( $pending_comments ) + echo ''; + ?> +
+ + > + + + + " . esc_html__( 'Edit', 'wp-e-commerce' ) . ""; } ?> + + ID) . "' class='delete'>" . __( 'Delete', 'wp-e-commerce' ) . ""; } ?> + + ID ); ?> + + >ID ); ?> + + +post_type && 'trash' == $post->post_status && !in_array('trash', $post_status)) + $post_status[] = 'Trash'; + + return $post_status; +} + +function wpsc_product_label_forms() { + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + return false; +} + +function wpsc_convert_weights($weight, $unit) { + _wpsc_deprecated_function( __FUNCTION__, '3.8', 'wpsc_convert_weight' ); + if (is_array($weight)) { + $weight = $weight['weight']; + } + return wpsc_convert_weight( $weight, $unit, 'gram', true ); +} + +/** + * wpsc in the loop function, + * @return boolean - true if we are in the loop + */ +function wpsc_in_the_loop() { + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + global $wpsc_query; + return $wpsc_query->in_the_loop; +} + +/** + * wpsc rewind products function, rewinds back to the first product + * @return nothing + */ +function wpsc_rewind_products() { + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + global $wpsc_query; + return $wpsc_query->rewind_posts(); +} + +/** + * wpsc product has file function + * @return boolean - true if the product has a file + */ +function wpsc_product_has_file() { + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + global $wpsc_query, $wpdb; + if ( is_numeric( $wpsc_query->product['file'] ) && ($wpsc_query->product['file'] > 0) ) + return true; + + return false; +} + +/** + * wpsc currency sign function + * @return string - the selected currency sign for the store + */ +function wpsc_currency_sign() { + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + global $wpdb; + $currency_sign_location = get_option( 'currency_sign_location' ); + $currency_type = get_option( 'currency_type' ); + $currency_symbol = $wpdb->get_var( $wpdb->prepare( "SELECT `symbol_html` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id` = %d LIMIT 1", $currency_type ) ); + + return $currency_symbol; +} + +/** + * wpsc page is selected function + * @return boolean - true if the page is selected + */ +function wpsc_page_is_selected() { + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + // determine if we are on this page + global $wpsc_query; + return $wpsc_query->page['selected']; +} + +/** + * wpsc page URL function + * @return string - the page URL + */ +function wpsc_page_url() { + _wpsc_deprecated_function( __FUNCTION__, '3.8' ); + // generate the page URL + global $wpsc_query; + return $wpsc_query->page['url']; +} + +function shipwire_build_xml( $log_id ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8.9', 'WPSC_Shipwire' ); + return WPSC_Shipwire::get_order_xml( $log_id ); +} + +function shipwire_built_sync_xml() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.9', 'WPSC_Shipwire' ); + return WPSC_Shipwire::get_inventory_xml(); +} + +function shipwire_built_tracking_xml() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.9', 'WPSC_Shipwire' ); + return WPSC_Shipwire::get_tracking_xml(); +} + +function shipwire_send_sync_request( $xml ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8.9', 'WPSC_Shipwire' ); + return WPSC_Shipwire::send_inventory_request( $xml ); +} + +function shipwire_sent_request( $xml ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8.9', 'WPSC_Shipwire' ); + return WPSC_Shipwire::send_order_request( $xml ); +} + +function shipwire_send_tracking_request( $xml ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8.9', 'WPSC_Shipwire' ); + return WPSC_Shipwire::send_tracking_request( $xml ); +} + +function wpsc_rage_where( $where ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8.8', 'wpsc_range_where()' ); + return wpsc_range_where( $where ); +} + +/** + * WPSC Product Variation Price Available + * Gets the formatted lowest price of a product's available variations. + * + * @param $product_id (int) Product ID + * @param $from_text (string) From text with price placeholder eg. 'from %s' + * @param $only_normal_price (bool) Don't show sale price + * @return (string) Number formatted price + * + * @uses wpsc_product_variation_price_from() + */ +function wpsc_product_variation_price_available( $product_id, $from_text = false, $only_normal_price = false ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8.10', 'wpsc_product_variation_price_from()' ); + $args = array( + 'from_text' => $from_text, + 'only_normal_price' => $only_normal_price, + 'only_in_stock' => true + ); + return wpsc_product_variation_price_from( $product_id, $args ); +} + +/** + * Deprecated function + * + * @deprecated 3.8.9 + */ +function wpsc_post_title_seo( $title ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8.9' ); + global $wpdb, $page_id, $wp_query; + $new_title = wpsc_obtain_the_title(); + if ( $new_title != '' ) { + $title = $new_title; + } + return esc_html( $title ); +} + +function wpsc_product_image_forms() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.13' ); + + global $post; + + edit_multiple_image_gallery( $post ); + +?> + +

>

+ID > 0 ) { + if ( has_post_thumbnail( $post->ID ) ) + echo get_the_post_thumbnail( $post->ID, 'admin-product-thumbnails' ); + + $args = array( + 'post_type' => 'attachment', + 'numberposts' => -1, + 'post_status' => null, + 'post_parent' => $post->ID, + 'orderby' => 'menu_order', + 'order' => 'ASC' + ); + + $attached_images = (array)get_posts( $args ); + + if ( count( $attached_images ) > 0 ) { + foreach ( $attached_images as $images ) { + $attached_image = wp_get_attachment_image( $images->ID, 'admin-product-thumbnails' ); + echo $attached_image. ' '; + } + } + + } +} + +function wpsc_media_upload_tab_gallery( $tabs ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8.13' ); + + unset( $tabs['gallery'] ); + $tabs['gallery'] = __( 'Product Image Gallery', 'wp-e-commerce' ); + + return $tabs; +} + +function wpsc_media_upload_url( $form_action_url ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8.13' ); + + $form_action_url = esc_url( add_query_arg( array( 'parent_page'=>'wpsc-edit-products' ) ) ); + + return $form_action_url; + +} + +function wpsc_gallery_css_mods() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.13' ); + + print ''; + print ' + '; +} + +function wpsc_filter_delete_text( $translation, $text, $domain ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8.13' ); + + if ( 'Delete' == $text && isset( $_REQUEST['post_id'] ) && isset( $_REQUEST['parent_page'] ) ) { + $translations = &get_translations_for_domain( $domain ); + return $translations->translate( 'Trash' ) ; + } + return $translation; +} + +/* + * This filter translates string before it is displayed + * specifically for the words 'Use as featured image' with 'Use as Product Thumbnail' when the user is selecting a Product Thumbnail + * using media gallery. + * + * @todo As this feature is entirely cosmetic and breaks with WP_DEBUG on in WP 3.5+, we've removed the filter for it. Will revisit the functionality in 3.9 when we look at new media workflows. + * @param $translation The current translation + * @param $text The text being translated + * @param $domain The domain for the translation + * @return string The translated / filtered text. + */ +function wpsc_filter_feature_image_text( $translation, $text, $domain ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8.13' ); + if ( 'Use as featured image' == $text && isset( $_REQUEST['post_id'] ) ) { + $post = get_post( $_REQUEST['post_id'] ); + if ( $post->post_type != 'wpsc-product' ) return $translation; + $translations = &get_translations_for_domain( $domain ); + return $translations->translate( 'Use as Product Thumbnail', 'wp-e-commerce' ); + //this will never happen, this is here only for gettexr to pick up the translation + return __( 'Use as Product Thumbnail', 'wp-e-commerce' ); + } + + return $translation; +} + +function wpsc_display_invoice() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.13' ); + + if ( ! wpsc_is_store_admin() ) { + return; + } + + $purchase_id = (int)$_REQUEST['purchaselog_id']; + add_action('wpsc_packing_slip', 'wpsc_packing_slip'); + do_action('wpsc_before_packing_slip', $purchase_id); + do_action('wpsc_packing_slip', $purchase_id); + exit(); +} + +function wpsc_packing_slip( $purchase_id ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8.13' ); + echo "" . __( 'Packing Slip', 'wp-e-commerce' ) . ""; + global $wpdb; + $purch_sql = $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `id`=%d", $purchase_id ); + $purch_data = $wpdb->get_row( $purch_sql, ARRAY_A ) ; + + $cartsql = $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`=%d", $purchase_id ); + $cart_log = $wpdb->get_results($cartsql,ARRAY_A) ; + $j = 0; + + if($cart_log != null) { + echo "
\n\r"; + echo apply_filters( 'wpsc_packing_slip_header', '

' . esc_html__( 'Packing Slip', 'wp-e-commerce' ) . "

\n\r" ); + echo "". esc_html__( 'Order', 'wp-e-commerce' )." # ".$purchase_id."

\n\r"; + + echo "\n\r"; + + $form_sql = $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_SUBMITTED_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 `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `active` = '1' ORDER BY `checkout_order`" , ARRAY_A ); + + foreach($form_data as $form_field) { + + switch($form_field['type']) { + case 'country': + $region_count_sql = $wpdb->prepare( "SELECT COUNT(`regions`.`id`) FROM `".WPSC_TABLE_REGION_TAX."` AS `regions` INNER JOIN `".WPSC_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 " \n\r"; + + echo " \n\r"; + break; + + case 'delivery_country': + + if(is_numeric($purch_data['shipping_region']) && ($delivery_region_count > 0)) + echo " \n\r"; + + echo " \n\r"; + break; + + case 'heading': + + if($form_field['name'] == "Hidden Fields") + break; + else + echo " \n\r"; + break; + + default: + if ($form_field['name']=="State" && !empty($purch_data['billing_region']) || $form_field['name']=="State" && !empty($purch_data['billing_region'])) + echo ""; + else + echo " \n\r"; + break; + } + + } + } else { + echo " \n\r"; + echo " \n\r"; + echo " \n\r"; + echo " \n\r"; + } + + if ( 2 == get_option( 'payment_method' ) ) { + $gateway_name = ''; + global $nzshpcrt_gateways; + + foreach( $nzshpcrt_gateways as $gateway ) { + if ( $purch_data['gateway'] != 'testmode' ) { + if ( $gateway['internalname'] == $purch_data['gateway'] ) { + $gateway_name = $gateway['name']; + } + } else { + $gateway_name = esc_html__('Manual Payment', 'wp-e-commerce'); + } + } + } + + echo "
".esc_html__('State', 'wp-e-commerce').":".wpsc_get_region($purch_data['billing_region'])."
" . esc_html( $form_field['name'] ) . ":" . esc_html( $rekeyed_input[$form_field['id']]['value'] ) . "
".esc_html__('State', 'wp-e-commerce').":".wpsc_get_region($purch_data['shipping_region'])."
" . esc_html( $form_field['name'] ) . ":" . esc_html( $rekeyed_input[ $form_field['id']]['value'] ) . "
" . esc_html( $form_field['name'] ) . ":
" . esc_html( $form_field['name'] ) . ":". + ( isset( $rekeyed_input[$form_field['id']] ) ? esc_html( $rekeyed_input[$form_field['id']]['value'] ) : '' ) . + "
".esc_html__('Name', 'wp-e-commerce').":".$purch_data['firstname']." ".$purch_data['lastname']."
".esc_html__('Address', 'wp-e-commerce').":".$purch_data['address']."
".esc_html__('Phone', 'wp-e-commerce').":".$purch_data['phone']."
".esc_html__('Email', 'wp-e-commerce').":".$purch_data['email']."
\n\r"; + + + do_action ('wpsc_packing_slip_extra_info',$purchase_id); + + + echo ""; + + echo ""; + echo " "; + + echo " "; + + + echo " "; + + echo " "; + echo ''; + echo ''; + $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 ""; + + + echo " "; + + echo " "; + + + echo " "; + + echo " "; + + + + echo ''; + echo ''; + } + + echo "
".esc_html__('Quantity', 'wp-e-commerce')." ".esc_html__('Name', 'wp-e-commerce')."".esc_html__('Price', 'wp-e-commerce')." ".esc_html__('Shipping', 'wp-e-commerce')." ' . esc_html__('Tax', 'wp-e-commerce') . '
"; + echo $cart_row['quantity']; + echo " "; + echo apply_filters( 'the_title', $cart_row['name'] ); + echo $variation_list; + echo " "; + echo wpsc_currency_display( $price ); + echo " "; + echo wpsc_currency_display($shipping ); + echo " '; + echo wpsc_currency_display( $cart_row['tax_charged'] ); + echo '
"; + echo ''; + if ( floatval( $purch_data['discount_value'] ) ) + echo ''; + + echo ''; + echo ''; + //wpec_taxes + if($purch_data['wpec_taxes_total'] != 0.00) + { + echo ''; + } + echo ''; + echo '
'.esc_html__('Discount', 'wp-e-commerce').'(' . wpsc_currency_display( $purch_data['discount_value'] ) . ')
'.esc_html__('Base Shipping','wp-e-commerce').'' . wpsc_currency_display( $purch_data['base_shipping'] ) . '
'.esc_html__('Total Shipping','wp-e-commerce').'' . wpsc_currency_display( $purch_data['base_shipping'] + $total_shipping ) . '
'.esc_html__('Taxes','wp-e-commerce').'' . wpsc_currency_display( $purch_data['wpec_taxes_total'] ) . '
'.esc_html__('Total Price','wp-e-commerce').'' . wpsc_currency_display( $purch_data['totalprice'] ) . '
'; + + echo "
\n\r"; + } else { + echo "
".esc_html__('This users cart was empty', 'wp-e-commerce'); + } +} + +//other actions are here +if ( isset( $_GET['display_invoice'] ) && ( 'true' == $_GET['display_invoice'] ) ) + add_action( 'admin_init', 'wpsc_display_invoice', 0 ); + +if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( 'wpsc_display_invoice' == $_REQUEST['wpsc_admin_action'] ) ) + add_action( 'admin_init', 'wpsc_display_invoice' ); + + +/** + * Disable SSL validation for Curl. Added/removed on a per need basis, like so: + * + * add_filter('http_api_curl', 'wpsc_curl_ssl'); + * remove_filter('http_api_curl', 'wpsc_curl_ssl'); + * + * @param resource $ch + * @return resource $ch + **/ +function wpsc_curl_ssl( $ch ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8.13', "add_filter( 'https_ssl_verify', '__return_false' )" ); + + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); + return $ch; +} + + +/** + * Get cart item meta + * @access public + * + * @deprecated since 3.8.13 + */ +function wpsc_get_cartmeta( $cart_item_id, $meta_key ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8.13', 'wpsc_get_cart_item_meta'); + return wpsc_get_cart_item_meta( $cart_item_id, $meta_key, true ); +} + +/** + * Update cart item meta + * @access public + * + * @deprecated since 3.8.13 + */ +function wpsc_update_cartmeta( $cart_item_id, $meta_key, $meta_value ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8.13', 'wpsc_update_cart_item_meta'); + return wpsc_update_cart_item_meta( $cart_item_id, $meta_key, $meta_value ); +} + +/** + * Delete cart item meta + * @access public + * + * @deprecated since 3.8.13 + */ +function wpsc_delete_cartmeta( $cart_item_id, $meta_key, $meta_value = '' ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8.13', 'wpsc_delete_cart_item_meta'); + return wpsc_delete_cart_item_meta( $cart_item_id, $meta_key, $meta_value ); +} + +function wpsc_get_exchange_rate( $from, $to ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8.13' ); + return _wpsc_get_exchange_rate( $from, $to ); +} + + +/** + * @access public + * @param unknown $stuff + * @param unknown $post_ID + * @return string + * @deprecated since 3.8.13.3 + */ +function wpsc_the_featured_image_fix( $stuff, $post_ID ){ + _wpsc_deprecated_function( __FUNCTION__, '3.8.13.2', 'wpsc_the_featured_image_fix'); + global $wp_query; + + $is_tax = is_tax( 'wpsc_product_category' ); + + $queried_object = get_queried_object(); + $is_single = is_single() && $queried_object->ID == $post_ID && get_post_type() == 'wpsc-product'; + + if ( $is_tax || $is_single ) { + $header_image = get_header_image(); + $stuff = ''; + + if ( $header_image ) + $stuff = ''; + } + + remove_action( 'post_thumbnail_html', 'wpsc_the_featured_image_fix' ); + + return $stuff; +} + +/** + * @access public + * @param string $meta_object_type Type of object metadata is for (e.g., variation. cart, etc) + * @return string Name of the custom meta table defined in $wpdb, or the name as it would be defined + * @deprecated since 3.8.13.4 + */ +function wpsc_meta_table_name( $meta_object_type ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8.14', '_wpsc_meta_table_name' ); + return _wpsc_meta_table_name( $meta_object_type ); +} + +/** + * Google checkout not longer available or supported, so we are deprecating this function + * + * @access public + * @deprecated since 3.8.14 + */ +function wpsc_google_checkout(){ + $currpage = wpsc_selfURL(); + if (array_search("google",(array)get_option('custom_gateway_options')) !== false && $currpage != get_option('shopping_cart_url')) { + global $nzshpcrt_gateways; + foreach($nzshpcrt_gateways as $gateway) { + if($gateway['internalname'] == 'google' ) { + $gateway_used = $gateway['internalname']; + $gateway['function'](true); + } + } + } +} + +/** + * Google checkout not longer available or supported, so we are deprecating this function + * + * @access public + * @deprecated since 3.8.14 + */ +function wpsc_empty_google_logs(){ + global $wpdb; + _wpsc_deprecated_function( __FUNCTION__, '3.8.14', 'wpsc_empty_google_logs' ); + $sql = $wpdb->prepare( "DELETE FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid` = '%s'", wpsc_get_customer_meta( 'checkout_session_id' ) ); + $wpdb->query( $sql ); + wpsc_delete_customer_meta( 'checkout_session_id' ); +} + +/** + * @access public + * @deprecated since 3.8.13.4 + */ +function wpsc_user_dynamic_js() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.14', 'wpsc_javascript_localizations' ); +} + +/* + * Over time certain javascript variables that were once localized into scripts will become obsolete + * When they do moving them here will continue to create the variables for older javascript to use. + */ +function _wpsc_deprecated_javascript_localization_vars() { + + /** + * @deprecated since 3.8.14 + * + * wpsc_deprecated_vars as an object with the properties below has been replaced and each of the properties + * is available as it's own variable, that means devs instead of referencing "wpsc_ajax.base_url" do + * "base_url" + */ + + $wpsc_deprecated_js_vars = array(); + + $wpsc_deprecated_js_vars['WPSC_DIR_NAME'] = WPSC_DIR_NAME; + $wpsc_deprecated_js_vars['fileLoadingImage'] = WPSC_CORE_IMAGES_URL . '/loading.gif'; + $wpsc_deprecated_js_vars['fileBottomNavCloseImage'] = WPSC_CORE_IMAGES_URL . '/closelabel.gif'; + $wpsc_deprecated_js_vars['resizeSpeed'] = 9; // controls the speed of the image resizing (1=slowest and 10=fastest) + $wpsc_deprecated_js_vars['borderSize'] = 10; //if you adjust the padding in the CSS, you will need to update this variable + + return $wpsc_deprecated_js_vars; +} + +/** + * wpsc google checkout submit used for google checkout (unsure whether necessary in 3.8) + * @access public + * + * @deprecated since 3.8.14 + */ +function wpsc_google_checkout_submit() { + + _wpsc_deprecated_function( __FUNCTION__, '3.8.14' ); + + global $wpdb, $wpsc_cart, $current_user; + $wpsc_checkout = new wpsc_checkout(); + $purchase_log_id = $wpdb->get_var( "SELECT `id` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid` IN(%s) LIMIT 1", wpsc_get_customer_meta( 'checkout_session_id' ) ); + get_currentuserinfo(); + if ( $current_user->display_name != '' ) { + foreach ( $wpsc_checkout->checkout_items as $checkoutfield ) { + if ( $checkoutfield->unique_name == 'billingfirstname' ) { + $checkoutfield->value = $current_user->display_name; + } + } + } + if ( $current_user->user_email != '' ) { + foreach ( $wpsc_checkout->checkout_items as $checkoutfield ) { + if ( $checkoutfield->unique_name == 'billingemail' ) { + $checkoutfield->value = $current_user->user_email; + } + } + } + + $wpsc_checkout->save_forms_to_db( $purchase_log_id ); + $wpsc_cart->save_to_db( $purchase_log_id ); + $wpsc_cart->submit_stock_claims( $purchase_log_id ); +} + +/** + * + * @deprecated 3.8.14 + * @uses apply_filters() Allows manipulation of the flash upload params. + */ +function wpsc_admin_dynamic_css() { + + _wpsc_deprecated_function( __FUNCTION__, '3.8.14' ); + + header( 'Content-Type: text/css' ); + header( 'Expires: ' . gmdate( 'r', mktime( 0, 0, 0, date( 'm' ), ( date( 'd' ) + 12 ), date( 'Y' ) ) ) . '' ); + header( 'Cache-Control: public, must-revalidate, max-age=86400' ); + header( 'Pragma: public' ); + $flash = 0; + $flash = apply_filters( 'flash_uploader', $flash ); + + if ( 1 == $flash ) { +?> + div.flash-image-uploader { + display: block; + } + + div.browser-image-uploader { + display: none; + } + + div.flash-image-uploader { + display: none; + } + + div.browser-image-uploader { + display: block; + } + +
+

+ a bug in WordPress prior to version 3.3, you might run into 404 errors when viewing your products. To work around this, upgrade to WordPress 3.3 or later, or simply click "Save Changes" below a second time.' , 'wp-e-commerce' ), 'http://core.trac.wordpress.org/ticket/16736', 'http://codex.wordpress.org/Updating_WordPress' ); ?> +

+
+ id != 'wpsc-product' ) + return $context; + return __( 'Upload Image%s', 'wp-e-commerce' ); + + } +} + +if ( ! function_exists( 'change_link' ) ) { + function change_link( $link ) { + _wpsc_deprecated_function( __FUNCTION__, '3.8.14' ); + + global $post_ID; + $current_screen = get_current_screen(); + if ( $current_screen && $current_screen->id != 'wpsc-product' ) + return $link; + + $uploading_iframe_ID = $post_ID; + $media_upload_iframe_src = "media-upload.php?post_id=$uploading_iframe_ID"; + + return $media_upload_iframe_src . "&type=image&parent_page=wpsc-edit-products"; + } +} + +function wpsc_google_shipping_settings() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.14' ); + + if ( ! wpsc_is_store_admin() ) { + return; + } + + if ( isset( $_POST['submit'] ) ) { + foreach ( (array) $_POST['google_shipping'] as $key => $country ) { + if ( $country == 'on' ) { + $google_shipping_country[] = $key; + $updated++; + } + } + update_option( 'google_shipping_country', $google_shipping_country ); + $sendback = wp_get_referer(); + $sendback = remove_query_arg( 'googlecheckoutshipping', $sendback ); + + if ( isset( $updated ) ) { + $sendback = add_query_arg( 'updated', $updated, $sendback ); + } + + wp_redirect( esc_url_raw( $sendback ) ); + exit(); + } +} + +if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'google_shipping_settings') ) { + add_action( 'admin_init', 'wpsc_google_shipping_settings' ); +} + +function wpsc_css_header() { + _wpsc_deprecated_function( __FUNCTION__, '3.8.14' ); +} + +/** + * deprecating item filters from wpsc_display_form_fields() in release 3.8.13.4 + * + * @deprecated 3.8.14 + * + * This function displays each of the form fields. + * + * Each of them are filterable via 'wpsc_account_form_field_$tag' + * where tag is permalink-styled name or uniquename. i.e. First Name under Shipping would be + * 'wpsc_account_form_field_shippingfirstname' - while Your Billing Details would be filtered + * via 'wpsc_account_form_field_your-billing-details'. + * + * @param varies $meta_value + * @param string $meta_key + * + */ +function wpsc_user_log_deprecated_filter_values( $meta_value, $meta_key ) { + $filter = 'wpsc_account_form_field_' . $meta_key; + if ( has_filter( $filter ) ) { + $meta_value = apply_filters( $filter , esc_html( $meta_value ) ); + _wpsc_doing_it_wrong( $filter, __( 'The filter being used has been deprecated. Use wpsc_get_visitor_meta or wpsc_get_visitor_meta_$meta_name instead.', 'wp-e-commerce' ), '3.8.14' ); + } + + return $meta_value; +} +add_filter( 'wpsc_get_visitor_meta', 'wpsc_user_log_deprecated_filter_values', 10, 2 ); + +/** + * deprecating user log filter for getting all customer meta as an array. + * + *@deprecated 3.8.14 + * + * @return none + */ +function wpsc_deprecated_filter_user_log_get() { + if ( has_filter( 'wpsc_user_log_get' ) ) { + $meta_data = wpsc_get_customer_meta( 'checkout_details' ); + $meta_data = apply_filters( 'wpsc_user_log_get', $meta_data, wpsc_get_current_customer_id() ); + wpsc_update_customer_meta( 'checkout_details', $meta_data ); + _wpsc_doing_it_wrong( 'wpsc_user_log_get', __( 'The filter being used has been deprecated. Use wpsc_get_visitor_meta or wpsc_get_visitor_meta_$meta_name instead.', 'wp-e-commerce' ), '3.8.14' ); + } +} + +add_action( 'wpsc_start_display_user_log_form_fields', 'wpsc_deprecated_filter_user_log_get', 10, 0 ); + + +/** + * function to provide deprecated variables to older shipping modules + * + * @since 3.8.14 + */ +function wpsc_deprecated_vars_for_shipping( $wpsc_cart ) { + // extracted from the Instinct fedex module + $_POST['country'] = wpsc_get_customer_meta( 'shippingcountry' ); + $_POST['region'] = wpsc_get_customer_meta( 'shippingregion' ); + $_POST['zipcode'] = wpsc_get_customer_meta( 'shippingpostcode' ); +} + +add_action( 'wpsc_before_get_shipping_method', 'wpsc_deprecated_vars_for_shipping' ); + +function _wpsc_action_user_update_errors( $errors, $update, $user ) { + if ( isset( $user->role ) && $user->role == 'wpsc_anonymous' ) { + unset( $errors->errors['empty_email'] ); + } +} + +// add_action( 'user_profile_update_errors', '_wpsc_action_user_update_errors', 10, 3 ); + +/** + * Not yet deprecated, but should be considered deprecated. + * + * Used only in TEv1 user account page. + * + * @param $selected_country + * @return + */ +function nzshpcrt_country_list( $selected_country = null ) { + return _wpsc_country_dropdown_options( array( + 'selected' => $selected_country, + ) ); +} + +/** + * Not yet deprecated, but should be considered deprecated. + * + * Used only in TEv1 user account page. + * + * @param [type] $selected_country [description] + * @param [type] $selected_region [description] + * @return [type] [description] + */ +function nzshpcrt_region_list( $selected_country = null, $selected_region = null ) { + global $wpdb; + + if ( $selected_region == null ) + $selected_region = get_option( 'base_region' ); + + $output = ''; + $region_list = WPSC_Countries::get_regions( $selected_country, true ); + + if ( $region_list != null ) { + foreach ( $region_list as $region ) { + if ( $selected_region == $region['id'] ) { + $selected = "selected='selected'"; + } else { + $selected = ""; + } + + $output .= "\r\n"; + } + } else { + $output .= "\r\n"; + } + + return $output; +} + +/** + * Not yet deprecated, but should be considered deprecated. + * + * Used only in PayPal Standard and Chronopay gateways. + * + * @param [type] $selected_field [description] + * @return [type] [description] + */ +function nzshpcrt_form_field_list( $selected_field = null ) { + global $wpdb; + $output = ""; + $form_sql = "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1';"; + $form_data = $wpdb->get_results( $form_sql, ARRAY_A ); + + foreach ( (array)$form_data as $form ) { + $selected = ''; + if ( $selected_field == $form['id'] ) { + $selected = "selected='selected'"; + } + $output .= ""; + } + + return $output; +} + +function wpsc_sanitise_keys($value) { + _wpsc_deprecated_function( __FUNCTION__, '4.0' ); + /// Function used to cast array items to integer. + return (int)$value; +} + +/** + * Duplicates a product + * + * @uses WPSC_Duplicate_Product Duplicate product class. + * + * @param object $post The post object. + * @param int|bool $new_parent_id Optional. The parent post ID or false. + * @return int|WP_Error New post ID or error. + * + * @deprecated since 4.0 + */ +function wpsc_duplicate_product_process( $post, $new_parent_id = false ) { + + _wpsc_deprecated_function( __FUNCTION__, '4.0', 'WPSC_Duplicate_Product->duplicate_product_process()' ); + + $duplicate = new WPSC_Duplicate_Product( $post->ID, $new_parent_id ); + + return $duplicate->duplicate_product_process(); + +} + +/** + * Copy the taxonomies of a post to another post + * + * @uses WPSC_Duplicate_Product Duplicate product class. + * + * @param int $id ID of the post we are duping. + * @param int $new_id ID of the new post. + * @param string $post_type The post type we are setting. + * + * @deprecated since 4.0 + */ +function wpsc_duplicate_taxonomies( $id, $new_id, $post_type ) { + + _wpsc_deprecated_function( __FUNCTION__, '4.0', 'WPSC_Duplicate_Product->duplicate_taxonomies()' ); + + $duplicate = new WPSC_Duplicate_Product( $id, false, $new_id ); + $duplicate->duplicate_taxonomies(); + +} + +/** + * Copy the meta information of a post to another post + * + * @uses WPSC_Duplicate_Product Duplicate product class. + * + * @param int $id ID of the post we are duping. + * @param int $new_id ID of the new post. + * + * @deprecated since 4.0 + */ +function wpsc_duplicate_product_meta( $id, $new_id ) { + + _wpsc_deprecated_function( __FUNCTION__, '4.0', 'WPSC_Duplicate_Product->duplicate_product_meta()' ); + + $duplicate = new WPSC_Duplicate_Product( $id, false, $new_id ); + $duplicate->duplicate_product_meta(); + +} + +/** + * Update Duplicate Product Gallery Meta + * + * When a product is duplicated it's meta values are copied too + * including the gallery meta array of IDs. + * + * After the product's children (including attachments) have been + * duplicated this function is used to update the gallery meta to + * refer to the IDs of any duplicated media. + * + * @param int $post_id Original product post ID. + * @param int $new_post_id Duplicated product post ID. + * @param array $duplicated_children Associative array mapping original child IDs to duplicated child IDs. + * + * @deprecated since 4.0 + */ +function wpsc_update_duplicate_product_gallery_meta( $post_id, $new_post_id, $duplicated_children ) { + + _wpsc_deprecated_function( __FUNCTION__, '4.0' ); + +} + +/** + * Duplicate Featured Image + * + * When a product is duplicated, the featured image ID is copied when the post + * meta is duplicated. + * + * When the featured image is attached to the duplicated product, if the image + * is duplicated the featured image ID is updated to the duplicated image ID + * otherwise the featured image ID is removed. + * + * If the featured image is not attached to the product the featured image ID + * remains the same as the original product. + * + * This function will remove the featured image if the image is not attached to + * the duplicated product and offers the opportunity to change the featured image + * of the duplicated product via the 'wpsc_duplicate_product_thumbnail' filter. + * + * @uses WPSC_Duplicate_Product Duplicate product class. + * + * @param integer $post_id Product ID. + * @param integer $new_post_id Duplicated product ID. + * + * @deprecated since 4.0 + */ +function wpsc_duplicate_product_thumbnail( $post_id, $new_post_id ) { + + _wpsc_deprecated_function( __FUNCTION__, '4.0', 'WPSC_Duplicate_Product->duplicate_product_thumbnail()' ); + + $duplicate = new WPSC_Duplicate_Product( $post_id, false, $new_post_id ); + $duplicate->duplicate_product_thumbnail(); + +} + +/** + * Duplicates product children and meta + * + * @uses WPSC_Duplicate_Product Duplicate product class. + * + * @param int $old_parent_id Post id for old parent. + * @param int $new_parenc_id Post id for the new parent. + * @return array Array mapping old child IDs to duplicated child IDs. + * + * @deprecated since 4.0 + */ +function wpsc_duplicate_children( $old_parent_id, $new_parent_id ) { + + _wpsc_deprecated_function( __FUNCTION__, '4.0', 'WPSC_Duplicate_Product->duplicate_children()' ); + + $duplicate = new WPSC_Duplicate_Product( $old_parent_id, false, $new_parent_id ); + + return $duplicate->duplicate_children(); + +} + +/** + * Duplicates a product image. + * + * Uses a portion of code from media_sideload_image() in `wp-admin/includes/media.php` + * to check file before downloading from URL. + * + * @since 3.9.0 + * + * @uses WPSC_Duplicate_Product Duplicate product class. + * + * @param object $post The post object. + * @param bool $new_parent_id The parent post id. + * @return int|bool Attachment ID or false. + * + * @deprecated since 4.0 + */ +function wpsc_duplicate_product_image_process( $child_post, $new_parent_id ) { + + _wpsc_deprecated_function( __FUNCTION__, '4.0', 'WPSC_Duplicate_Product->duplicate_product_image_process()' ); + + $duplicate = new WPSC_Duplicate_Product( $child_post->ID, $new_parent_id ); + $duplicate->duplicate_product_image_process(); + +} + +/** + * Fancy Notifications + * + * @deprecated Since 4.0. Use WPSC_Fancy_Notifications::fancy_notifications() instead. + * + * @uses WPSC_Fancy_Notifications Fancy notifications class. + * + * @return string Fancy Notification HTML. + */ +function fancy_notifications() { + + return WPSC_Fancy_Notifications::fancy_notifications( true ); + +} + +/** + * Fancy Notifications + * + * @deprecated Since 4.0. Use WPSC_Fancy_Notifications::fancy_notifications() instead. + * + * @uses WPSC_Fancy_Notifications Fancy notifications class. + * + * @param boolean $return Return or echo. + * @return string Fancy Notification HTML. + */ +function wpsc_fancy_notifications( $return = false ) { + + if ( $return ) { + return WPSC_Fancy_Notifications::fancy_notifications( $return ); + } else { + echo WPSC_Fancy_Notifications::fancy_notifications( $return ); + } + +} + +/** + * Fancy Notification Content + * + * @deprecated Since 4.0. Use WPSC_Fancy_Notifications::fancy_notification_content() instead. + * + * @uses WPSC_Fancy_Notifications Fancy notifications class. + * + * @param array $cart_messages Cart messages. + * @return array Cart messages. + */ +function fancy_notification_content( $cart_messages ) { + + return WPSC_Fancy_Notifications::fancy_notification_content( $cart_messages ); + +} From f53aac2958988adb805a8a51feff065b07eb4496 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 18 Feb 2021 14:39:09 +0000 Subject: [PATCH 17/17] Revert "Delete cart-template-api.php" This reverts commit 1380802bdb1f971dbf6b948e389f55cedee180a2. --- wpsc-includes/cart-template-api.php | 663 ++++++++++++++++++++++++++++ 1 file changed, 663 insertions(+) create mode 100644 wpsc-includes/cart-template-api.php diff --git a/wpsc-includes/cart-template-api.php b/wpsc-includes/cart-template-api.php new file mode 100644 index 0000000000..b7e7e656de --- /dev/null +++ b/wpsc-includes/cart-template-api.php @@ -0,0 +1,663 @@ +needs_shipping_recalc(); + } + + return $result; +} + +/** + * Clear all shipping method information for the current customer cart + * + * @since 3.8.14 + * + * @uses wpsc_cart + * + */ +function wpsc_cart_clear_shipping_info() { + global $wpsc_cart; + + if ( _wpsc_verify_global_cart_has_been_initialized( __FUNCTION__ ) ) { + $wpsc_cart->clear_shipping_info(); + } +} + +/** + * tax is included function + * + * @uses wpec_taxes_controller + * + * @return boolean true or false depending on settings>general page + */ +function wpsc_tax_isincluded() { + //uses new wpec_taxes functionality now + + require_once( WPSC_FILE_PATH . '/wpsc-taxes/taxes_module.php' ); + + $wpec_taxes_controller = new wpec_taxes_controller(); + return $wpec_taxes_controller->wpec_taxes_isincluded(); +} + +/** + * cart item count function + * + * @uses wpsc_cart + * + * @return integer the item count + */ +function wpsc_cart_item_count() { + global $wpsc_cart; + + $count = 0; + + if ( _wpsc_verify_global_cart_has_been_initialized( __FUNCTION__ ) ) { + foreach ( (array)$wpsc_cart->cart_items as $cart_item ) { + $count += $cart_item->quantity; + } + } + + return $count; +} + +/** + * coupons price, used through ajax and in normal page loading. + * No parameters, returns nothing + */ +function wpsc_coupon_price( $currCoupon = '' ) { + global $wpsc_cart, $wpsc_coupons; + if ( isset( $_POST['coupon_num'] ) && $_POST['coupon_num'] != '' ) { + $coupon = esc_sql( $_POST['coupon_num'] ); + wpsc_update_customer_meta( 'coupon', $coupon ); + $wpsc_coupons = new wpsc_coupons( $coupon ); + + if ( $wpsc_coupons->validate_coupon() ) { + $discountAmount = $wpsc_coupons->calculate_discount(); + $wpsc_cart->apply_coupons( $discountAmount, $coupon ); + $wpsc_coupons->errormsg = false; + } else { + $wpsc_coupons->errormsg = true; + $wpsc_cart->coupons_amount = 0; + $wpsc_cart->coupons_name = ''; + wpsc_delete_customer_meta( 'coupon' ); + } + } else if ( (!isset( $_POST['coupon_num'] ) || $_POST['coupon_num'] == '') && $currCoupon == '' ) { + $wpsc_cart->coupons_amount = 0; + $wpsc_cart->coupons_name = ''; + } else if ( $currCoupon != '' ) { + $coupon = esc_sql( $currCoupon ); + wpsc_update_customer_meta( 'coupon', $coupon ); + $wpsc_coupons = new wpsc_coupons( $coupon ); + + if ( $wpsc_coupons->validate_coupon() ) { + $discountAmount = $wpsc_coupons->calculate_discount(); + $wpsc_cart->apply_coupons( $discountAmount, $coupon ); + $wpsc_coupons->errormsg = false; + } + } +} + +/** + * Get WPEC cart coupon value total + * + * @param boolean $format_for_display should the output formatted for display, or returned as a number + * + * @uses wpsc_cart + * + * @return integer the item count + */ +function wpsc_coupon_amount( $format_for_display = true ) { + global $wpsc_cart; + + $output = ''; + + if ( _wpsc_verify_global_cart_has_been_initialized( __FUNCTION__ ) ) { + if ( $format_for_display ) { + $output = wpsc_currency_display( $wpsc_cart->coupons_amount ); + } else { + $output = $wpsc_cart->coupons_amount; + } + } + + return $output; +} + +/** + * cart total function + * + * @param boolean $format_for_display should the output formatted for display, or returned as a number + * + * @uses wpsc_cart + * + * @return string the total price of the cart, with a currency sign + */ +function wpsc_cart_total( $format_for_display = true ) { + global $wpsc_cart; + $total = 0; + + if ( _wpsc_verify_global_cart_has_been_initialized( __FUNCTION__ ) ) { + + $total = $wpsc_cart->calculate_total_price(); + + if ( $format_for_display ) { + $total = wpsc_currency_display( $total ); + } + } + + return $total; +} + +/** + * nzshpcrt_overall_total_price function + * + * @uses wpsc_cart + * + * @return string the total price of the cart, with a currency sign, empty string on failure + */ +function nzshpcrt_overall_total_price() { + + global $wpsc_cart; + + if ( _wpsc_verify_global_cart_has_been_initialized( __FUNCTION__ ) ) { + return $wpsc_cart->calculate_total_price(); + } else { + return ''; + } + +} + +/** + * cart total weight function + * + * @uses wpsc_cart + * + * @return float the total weight of the cart + */ +function wpsc_cart_weight_total() { + global $wpsc_cart; + + if ( _wpsc_verify_global_cart_has_been_initialized( __FUNCTION__ ) ) { + return $wpsc_cart->calculate_total_weight( true ); + } else { + return 0.0; + } +} + +/** + * tax total function, no parameters + * + * @uses wpsc_cart + * + * @return float the total weight of the cart + */ +function wpsc_cart_tax( $format_for_display = true ) { + global $wpsc_cart; + + $cart_tax = $format_for_display ? '' : 0; + + if ( _wpsc_verify_global_cart_has_been_initialized( __FUNCTION__ ) ) { + if ( $format_for_display ) { + if ( ! wpsc_tax_isincluded() ) { + $cart_tax = wpsc_currency_display( $wpsc_cart->calculate_total_tax() ); + } else { + $cart_tax = '(' . wpsc_currency_display( $wpsc_cart->calculate_total_tax() ) . ')'; + } + } else { + $cart_tax = $wpsc_cart->calculate_total_tax(); + } + } + + return $cart_tax; +} + + +/** + * wpsc_cart_show_plus_postage function, no parameters + * For determining whether to show "+ Postage & tax" after the total price + * + * @uses wpsc_cart + * + * @return boolean true or false + */ +function wpsc_cart_show_plus_postage() { + + // TODO: Deprecate the use of $_SESSION for cart state, see github issue report #997 + // https://github.com/wp-e-commerce/WP-e-Commerce/issues/997 + if ( + isset( $_SESSION['wpsc_has_been_to_checkout'] ) + && ($_SESSION['wpsc_has_been_to_checkout'] == null ) + && ( get_option( 'add_plustax' ) == 1 + ) ) { + + return true; + + } else { + return false; + } +} + +/** + * Does the customers cart require/user shipping + * + * @uses wpsc_cart + * @return boolean if true, all items in the cart do use shipping + */ +function wpsc_uses_shipping() { + + //This currently requires + global $wpsc_cart; + + $shippingoptions = get_option( 'custom_shipping_options' ); + + if ( get_option( 'do_not_use_shipping' ) ) { + return false; + } + + $uses_shipping = false; + + if ( _wpsc_verify_global_cart_has_been_initialized( __FUNCTION__ ) ) { + + if ( ( ! ( ( get_option( 'shipping_discount' ) == 1 ) && ( get_option( 'shipping_discount_value' ) <= $wpsc_cart->calculate_subtotal() ) ) ) + || ( count( $shippingoptions ) >= 1 && $shippingoptions[0] != '') + ) { + $uses_shipping = (bool) $wpsc_cart->uses_shipping(); + } else { + $uses_shipping = false; + } + } + + return $uses_shipping; +} + +/** + * Check if the shipping charges are non-zero for the customer cart + * + * @uses wpsc_cart + * + * @return boolean true for yes, false for no + */ +function wpsc_cart_has_shipping() { + global $wpsc_cart; + + $has_shipping = false; + + if ( _wpsc_verify_global_cart_has_been_initialized( __FUNCTION__ ) ) { + if ( $wpsc_cart->calculate_total_shipping() > 0 ) { + $has_shipping = true; + } else { + $has_shipping = false; + } + } + + return $has_shipping; +} + + +/** + * Checks if the store has shipping enabled globally. + * + * @since 3.8.14.1 + * @return bool Whether or not shipping is enabled. + */ +function wpsc_is_shipping_enabled() { + return ! (bool) get_option( 'do_not_use_shipping', false ); +} + +/** + * Get cart total + * + * @uses wpsc_cart + * + * @return string the total shipping of the cart, with a currency sign + */ +function wpsc_cart_shipping() { + global $wpsc_cart; + + if ( _wpsc_verify_global_cart_has_been_initialized( __FUNCTION__ ) ) { + $result = wpsc_currency_display( $wpsc_cart->calculate_total_shipping() ); + } else { + $result = ''; + } + + $result = apply_filters( 'wpsc_cart_shipping', $result ); + + return $result; +} + + +/** + * Get cart item categories function + * + * @since + * @uses wpsc_cart + * + * @return array array of the categories + */ +function wpsc_cart_item_categories( $get_ids = false ) { + global $wpsc_cart; + + $categories = array(); + + if ( _wpsc_verify_global_cart_has_been_initialized( __FUNCTION__ ) ) { + if ( $get_ids ) { + $categories = $wpsc_cart->get_item_category_ids(); + } else { + $categories = $wpsc_cart->get_item_categories(); + } + } + + return $categories; +} + +/** + * Product Maximum Cart Quantity + * + * @since 3.8.10 + * @access public + * + * @param int $prod_id Optional. Product ID. + * @return int The maximum quantity that can be added to the cart. + * + * @uses apply_filters Calls 'wpsc_product_max_cart_quantity' passing product ID. + */ +function wpsc_product_max_cart_quantity( $product_id = 0 ) { + $product_id = absint( $product_id ); + return apply_filters( 'wpsc_product_max_cart_quantity', 10000, $product_id ); +} + +/** + * Product Minimum Cart Quantity + * + * @since 3.8.13 + * @access public + * + * @param int $prod_id Optional. Product ID. + * @return int The minimum quantity that can be added to the cart. + * + * @uses apply_filters Calls 'wpsc_product_min_cart_quantity' passing product ID. + */ +function wpsc_product_min_cart_quantity( $product_id = 0 ) { + $product_id = absint( $product_id ); + return apply_filters( 'wpsc_product_min_cart_quantity', 1, $product_id ); +} + +/** + * Validate Product Cart Quantity + * Checks that the quantity is within the permitted bounds and return a valid quantity. + * + * @since 3.8.10 + * @access public + * + * @param int $quantity Cart item product quantity. + * @param int $prod_id Optional. Product ID. + * @return int The maximum quantity that can be added to the cart. + * + * @uses wpsc_product_max_cart_quantity Gets the maximum product cart quantity. + * @uses wpsc_product_min_cart_quantity Gets the minimum product cart quantity. + * @uses wpsc_cart + */ +function wpsc_validate_product_cart_quantity( $quantity, $product_id = 0 ) { + + $max_quantity = wpsc_product_max_cart_quantity( $product_id ); + $min_quantity = wpsc_product_min_cart_quantity( $product_id ); + + if ( $quantity > $max_quantity ) { + return $max_quantity; + } + + if ( $quantity < $min_quantity ) { + return $min_quantity; + } + + return $quantity; +} + +/** + * Validate Cart Product Quantity + * Triggered by 'wpsc_add_item' and 'wpsc_edit_item' actions when products are added to the cart. + * + * @since 3.8.10 + * @access private + * + * @param int $product_id Cart product ID. + * @param array $parameters Cart item parameters. + * @param object $cart Cart object. + * + * @uses wpsc_cart + * @uses wpsc_validate_product_cart_quantity Filters and restricts the product cart quantity. + */ +function _wpsc_validate_cart_product_quantity( $product_id, $parameters, $cart ) { + foreach ( $cart->cart_items as $key => $cart_item ) { + if ( $cart_item->product_id == $product_id ) { + $cart->cart_items[ $key ]->quantity = wpsc_validate_product_cart_quantity( $cart->cart_items[ $key ]->quantity, $product_id ); + $cart->cart_items[ $key ]->refresh_item(); + } + } +} + +add_action( 'wpsc_add_item' , '_wpsc_validate_cart_product_quantity', 10, 3 ); +add_action( 'wpsc_edit_item', '_wpsc_validate_cart_product_quantity', 10, 3 ); + +/** + * cart all shipping quotes, used for google checkout + * returns all the quotes for a selected shipping method + * + * @since + * @access public + * + * @uses wpsc_cart + * + * @return array of shipping options +*/ +function wpsc_selfURL() { + $s = empty( $_SERVER ['HTTPS'] ) ? '' : ( $_SERVER ['HTTPS'] == 'on' ) ? 's' : ''; + $protocol = wpsc_strleft( strtolower( $_SERVER ['SERVER_PROTOCOL'] ), '/' ) . $s; + $port = ( $_SERVER ['SERVER_PORT'] == '80' ) ? '' : ( ':' . $_SERVER ['SERVER_PORT'] ); + return $protocol . '://' . $_SERVER ['SERVER_NAME'] . $port . $_SERVER ['REQUEST_URI']; +} + +function wpsc_strleft( $s1, $s2 ) { + $values = substr( $s1, 0, strpos( $s1, $s2 ) ); + return $values; +} + +/** + * WPEC cart API template function + * + * @since + * + * @param + * + * @uses wpsc_cart + */ +function wpsc_update_shipping_single_method(){ + global $wpsc_cart; + + if ( _wpsc_verify_global_cart_has_been_initialized( __FUNCTION__ ) ) { + if ( ! empty( $wpsc_cart->shipping_method ) ) { + $wpsc_cart->update_shipping( $wpsc_cart->shipping_method, $wpsc_cart->selected_shipping_option ); + } + } +} + +/** + * WPEC cart API template function + * + * @since + * + * @param + * + * @uses wpsc_cart + */ +function wpsc_update_shipping_multiple_methods(){ + global $wpsc_cart; + + if ( _wpsc_verify_global_cart_has_been_initialized( __FUNCTION__ ) ) { + if ( ! empty( $wpsc_cart->selected_shipping_method ) ) { + $wpsc_cart->update_shipping( $wpsc_cart->selected_shipping_method, $wpsc_cart->selected_shipping_option ); + } + } +} + +/** + * Get remaining product quantity + * + * @since + * @access public + * + * @param int $product_id Cart product ID. + * @param array $variations Cart item parameters. + * @param int $quantity Cart object. + * + * @uses wpsc_product_stock Filters and restricts the product cart quantity. + */ +function wpsc_get_remaining_quantity( $product_id, $variations = array(), $quantity = 1 ) { + + $stock = get_post_meta( $product_id, '_wpsc_stock', true ); + $stock = apply_filters( 'wpsc_product_stock', $stock, $product_id ); + $output = 0; + + // check to see if the product uses stock + if ( is_numeric( $stock ) ) { + + if ( $stock > 0 ) { + $claimed_query = new WPSC_Claimed_Stock( array( 'product_id' => $product_id ) ); + $claimed_stock = $claimed_query->get_claimed_stock_count(); + $output = $stock - $claimed_stock; + } + } + + return $output; +} + +/** + * Prior to using the global cart variable cart template API functions should check + * to be sure the global cart variable has been initialized. + * + * @access private + * @static + * @since 3.8.14 + * + * @uses wpsc_cart + * @return boolean true if we have a valid cart, false otherwise + * + */ +function _wpsc_verify_global_cart_has_been_initialized( $function = __FUNCTION__ ) { + + global $wpsc_cart; + + $we_have_a_valid_cart = ! empty( $wpsc_cart ) && is_a( $wpsc_cart, 'wpsc_cart' ); + + if ( ! $we_have_a_valid_cart ) { + $wpsc_cart = wpsc_get_customer_cart(); + $we_have_a_valid_cart = ! empty( $wpsc_cart ) && is_a( $wpsc_cart, 'wpsc_cart' ); + } + + // We will try to give a helpful message to the developer so that they can adjust their code + static $already_gave_no_valid_cart_message = false; + if ( ! $we_have_a_valid_cart && ! $already_gave_no_valid_cart_message ) { + _wpsc_doing_it_wrong( $function, __( 'The WPeC global cart is not yet initialized. Accessing global cart properties and methods will not work.', 'wp-e-commerce' ), '3.8.14' ); + $already_gave_no_valid_cart_message = true; + } + + return $we_have_a_valid_cart; +} + +/** + * Checks if the current cart is a "Free Cart", which means one of the following: + * + * - Either the all of the cart items are priced at 0. + * - Or a coupon has been applied that results in a free cart. + * + * This is a helpful function for doing things like allowing free carts to be purchased, bypassing payment gateways. + * + * @since 3.9.0 + * @return bool Whether or not the current cart's total cost is free or not. + */ +function wpsc_is_free_cart() { + return apply_filters( 'wpsc_is_free_cart', wpsc_cart_item_count() && ! floatval( wpsc_cart_total( false ) ) ); +} + +/** + * Allows users to checkout with a free cart. + * + * If developers or users would rather inhibit this functionality, as it was prior to 3.9.0, they can + * add the following code (prior to 'init', priority 2) to a theme or plugin: + * add_filter( 'wpsc_allow_free_cart_checkout', '__return_false' ); + * + * @since 3.9.0 + * @return void + */ +function wpsc_allow_free_cart_checkout() { + + if ( wpsc_is_free_cart() && apply_filters( 'wpsc_allow_free_cart_checkout', true ) ) { + + /* Required for compatibility with the 3.0 payment gateway API and the 2.0 theme engine */ + add_filter( 'wpsc_payment_method_form_fields', '__return_empty_array' ); + + /* Sets the status entered to the "Accepted Payment" status and sets a 'free' gateway name. */ + add_filter( 'wpsc_purchase_log_insert_data', 'wpsc_free_checkout_insert_order_status' ); + + /* Handles what a gateway would properly handle, updating the "processed" key in the database. */ + add_action( 'wpsc_submit_checkout_gateway', 'wpsc_free_checkout_update_processed_status', 5, 2 ); + } + +} + +add_action( 'init', 'wpsc_allow_free_cart_checkout', 2 ); + +/** + * Updates the 'statusno' and 'gateway' parameters when a new order is submitted with a free cart. + * + * @param array $data Array of arguments passed to WPSC_Purchase_Log on a new order. + * @uses apply_filters 'wpsc_free_checkout_order_status' allows developers to change the status a free cart is saved with. + * @uses apply_filters 'wpsc_free_checkout_order_gateway' allows developers to change the gateway a free cart is saved with + * @since 3.9.0 + * + * @return array $data Modified array of arguments passed to WPSC_Purchase_Log on a new order. + */ +function wpsc_free_checkout_insert_order_status( $data ) { + $data['statusno'] = apply_filters( 'wpsc_free_checkout_order_status', WPSC_Purchase_Log::ACCEPTED_PAYMENT ); + $data['gateway'] = apply_filters( 'wpsc_free_checkout_order_gateway', 'free' ); + + return $data; +} + +/** + * Updates the 'processed' parameter after a new order is submitted with a free cart. + * + * @param string $gateway Name of gateway. In the case of a free cart, this will be empty. + * @param WPSC_Purchase_Log $log WPSC_Purchase_Log object. + * @uses apply_filters 'wpsc_free_checkout_order_status' allows developers to change the status a free cart is saved with. + * @since 3.9.0 + * + */ +function wpsc_free_checkout_update_processed_status( $gateway, $log ) { + + wpsc_update_purchase_log_status( + $log->get( 'id' ), + apply_filters( 'wpsc_free_checkout_order_status', WPSC_Purchase_Log::ACCEPTED_PAYMENT ) + ); + + wp_safe_redirect( add_query_arg( 'sessionid', $log->get( 'sessionid' ), get_option( 'transact_url' ) ) ); + exit; +}