From f830826ad815a53664dadff9bdec029d85e1976a Mon Sep 17 00:00:00 2001 From: WP Date: Mon, 17 Apr 2023 21:24:36 -0300 Subject: [PATCH] v2.9.5 --- cost-of-goods-for-woocommerce.php | 4 +- includes/alg-wc-cog-functions.php | 32 +- ...ass-alg-wc-cog-update-cost-bkg-process.php | 8 +- ...cog-update-variation-costs-bkg-process.php | 48 +++ includes/class-alg-wc-cog-orders.php | 14 +- ...class-alg-wc-cog-products-cost-archive.php | 21 +- includes/class-alg-wc-cog-products.php | 79 ++++- ...lass-alg-wc-cog-settings-compatibility.php | 4 +- .../tools/class-alg-wc-cog-bulk-edit-tool.php | 273 ++++++++++----- langs/cost-of-goods-for-woocommerce.pot | 310 +++++++++++------- readme.txt | 7 +- 11 files changed, 564 insertions(+), 236 deletions(-) create mode 100644 includes/background-process/class-alg-wc-cog-update-variation-costs-bkg-process.php diff --git a/cost-of-goods-for-woocommerce.php b/cost-of-goods-for-woocommerce.php index 15ae9b8..58fe5e0 100644 --- a/cost-of-goods-for-woocommerce.php +++ b/cost-of-goods-for-woocommerce.php @@ -3,7 +3,7 @@ Plugin Name: Cost of Goods for WooCommerce Plugin URI: https://wpfactory.com/item/cost-of-goods-for-woocommerce/ Description: Save product purchase costs (cost of goods) in WooCommerce. Beautifully. -Version: 2.9.4 +Version: 2.9.5 Author: WPFactory Author URI: https://wpfactory.com Text Domain: cost-of-goods-for-woocommerce @@ -72,7 +72,7 @@ final class Alg_WC_Cost_of_Goods { * @var string * @since 1.0.0 */ - public $version = '2.9.4'; + public $version = '2.9.5'; /** * @var Alg_WC_Cost_of_Goods The single instance of the class diff --git a/includes/alg-wc-cog-functions.php b/includes/alg-wc-cog-functions.php index c025fac..51f99ad 100644 --- a/includes/alg-wc-cog-functions.php +++ b/includes/alg-wc-cog-functions.php @@ -2,7 +2,7 @@ /** * Cost of Goods for WooCommerce - Functions. * - * @version 2.8.7 + * @version 2.9.5 * @since 1.4.0 * @author WPFactory */ @@ -219,6 +219,36 @@ function alg_wc_cog_get_blocked_options_message() { } } +if ( ! function_exists( 'alg_wc_cog_sanitize_number' ) ) { + + /** + * alg_wc_cog_sanitize_number. + * + * @version 2.9.5 + * @since 2.9.5 + * + * @param $args + * + * @return numeric + */ + function alg_wc_cog_sanitize_number( $args = null ) { + $args = wp_parse_args( $args, array( + 'number' => 0, + 'dots_and_commas_operation' => 'comma-to-dot', // comma-to-dot | dot-to-comma | none + ) ); + $args = apply_filters( 'alg_wc_cog_sanitize_number_args', $args ); + $number = $args['number']; + $dots_and_commas_operation = $args['dots_and_commas_operation']; + if ( 'comma-to-dot' === $dots_and_commas_operation ) { + $number = str_replace( ',', '.', $number ); + } elseif ( 'dot-to-comma' === $dots_and_commas_operation ) { + $number = str_replace( '.', ',', (string) $number ); + } + + return $number; + } +} + if ( ! function_exists( 'alg_wc_cog_get_regular_price' ) ) { /** * alg_wc_cog_get_regular_price. diff --git a/includes/background-process/class-alg-wc-cog-update-cost-bkg-process.php b/includes/background-process/class-alg-wc-cog-update-cost-bkg-process.php index f9f9d5a..8224299 100644 --- a/includes/background-process/class-alg-wc-cog-update-cost-bkg-process.php +++ b/includes/background-process/class-alg-wc-cog-update-cost-bkg-process.php @@ -1,8 +1,8 @@ core->products->update_product_cost_by_percentage( array( 'product_id' => $product_id, 'percentage' => $percentage, 'update_type' => $update_type, // profit | price + 'costs_filter' => $costs_filter, 'update_variations' => true ) ); return false; diff --git a/includes/background-process/class-alg-wc-cog-update-variation-costs-bkg-process.php b/includes/background-process/class-alg-wc-cog-update-variation-costs-bkg-process.php new file mode 100644 index 0000000..9367e83 --- /dev/null +++ b/includes/background-process/class-alg-wc-cog-update-variation-costs-bkg-process.php @@ -0,0 +1,48 @@ +core->products->update_variation_cost_from_parent( $item ); + return false; + } + } +endif; \ No newline at end of file diff --git a/includes/class-alg-wc-cog-orders.php b/includes/class-alg-wc-cog-orders.php index 74b25bd..8485538 100644 --- a/includes/class-alg-wc-cog-orders.php +++ b/includes/class-alg-wc-cog-orders.php @@ -2,7 +2,7 @@ /** * Cost of Goods for WooCommerce - Orders Class. * - * @version 2.9.4 + * @version 2.9.5 * @since 2.1.0 * @author WPFactory */ @@ -1069,7 +1069,7 @@ function get_shipping_total_for_percentage_fees( $order ) { /** * update_order_items_costs. * - * @version 2.9.1 + * @version 2.9.5 * @since 1.1.0 * @todo [maybe] filters: add more? * @todo [maybe] `$total_price`: customizable calculation method (e.g. `$order->get_subtotal()`) (this will affect `_alg_wc_cog_order_profit_margin`) @@ -1201,7 +1201,10 @@ function update_order_items_costs( $args ) { // calculate total profit, cost, handling fee per order items. $quantity = $calculate_qty_excluding_refunds ? $item->get_quantity() + $order->get_qty_refunded_for_item( $item_id ) : $item->get_quantity(); if ( '' !== $cost || '' !== $handling_fee ) { - $cost = str_replace( ',', '.', $cost ); + $cost = alg_wc_cog_sanitize_number( array( + 'number' => $cost, + 'dots_and_commas_operation' => 'comma-to-dot' + ) ); $cost = (float) $cost; $line_cost = $cost * $quantity; $item_line_total = $item['line_total']; @@ -1213,7 +1216,10 @@ function update_order_items_costs( $args ) { $items_cost += $line_cost; $total_price += $line_total; // handling fee. - $handling_fee = str_replace( ',', '.', $handling_fee ); + $handling_fee = alg_wc_cog_sanitize_number( array( + 'number' => $handling_fee, + 'dots_and_commas_operation' => 'comma-to-dot' + ) ); $handling_fee = (float) $handling_fee; $line_handling_fee = $handling_fee * $quantity; $profit -= $line_handling_fee; diff --git a/includes/class-alg-wc-cog-products-cost-archive.php b/includes/class-alg-wc-cog-products-cost-archive.php index e78aed7..538e6a4 100644 --- a/includes/class-alg-wc-cog-products-cost-archive.php +++ b/includes/class-alg-wc-cog-products-cost-archive.php @@ -2,7 +2,7 @@ /** * Cost of Goods for WooCommerce - Products - Cost archive. * - * @version 2.9.3 + * @version 2.9.5 * @since 2.8.2 * @author WPFactory */ @@ -65,9 +65,10 @@ function add_cost_archive_meta_box() { * @version 2.9.3 * @since 2.8.2 * - * @param null $args + * @param $args * * @return array + * @throws Exception */ function get_product_cost_archive( $args = null ) { $args = wp_parse_args( $args, array( @@ -122,7 +123,7 @@ function get_product_cost_archive( $args = null ) { /** * product_add_stock_meta_box. * - * @version 2.9.3 + * @version 2.9.5 * @since 2.8.2 * @todo [next] add option to delete all/selected history */ @@ -133,6 +134,7 @@ function display_product_cost_archive_table( $post ) { $product_cost_archive = $this->get_product_cost_archive( array( 'product_id' => $post->ID ) ); + //$sanitize_cost if ( empty( $product_cost_archive ) ) { echo '

'.__( 'There isn\'t a cost archive for this product yet.', 'cost-of-goods-for-woocommerce' ).'

'; echo '

' . sprintf( __( 'Please, check if the option %s is enabled and then update the cost.', 'cost-of-goods-for-woocommerce' ), '' . __( 'Products > Cost archive > Save cost archive', 'cost-of-goods-for-woocommerce' ) . '' ) . '

'; @@ -143,12 +145,21 @@ function display_product_cost_archive_table( $post ) { 'new_cost_value' => __( 'New cost', 'cost-of-goods-for-woocommerce' ), ); $table_rows = array(); + $dots_and_commas_operation = 'comma-to-dot'; foreach ( $product_cost_archive as $cost_info ) { + $prev_cost = alg_wc_cog_sanitize_number( array( + 'number' => $cost_info['prev_cost_value'], + 'dots_and_commas_operation' => $dots_and_commas_operation + ) ); + $new_cost_value = alg_wc_cog_sanitize_number( array( + 'number' => $cost_info['new_cost_value'], + 'dots_and_commas_operation' => $dots_and_commas_operation + ) ); $table_rows[] = array( 'val_by_col' => array( wp_date( get_option( 'alg_wc_cog_save_cost_archive_date_format', 'Y-m-d' ), $cost_info['update_date'] ), - alg_wc_cog_format_cost( $cost_info['prev_cost_value'] ), - alg_wc_cog_format_cost( $cost_info['new_cost_value'] ) + alg_wc_cog_format_cost( $prev_cost ), + alg_wc_cog_format_cost( $new_cost_value ) ) ); } diff --git a/includes/class-alg-wc-cog-products.php b/includes/class-alg-wc-cog-products.php index 6fa2774..ca81ea6 100644 --- a/includes/class-alg-wc-cog-products.php +++ b/includes/class-alg-wc-cog-products.php @@ -2,7 +2,7 @@ /** * Cost of Goods for WooCommerce - Products Class. * - * @version 2.9.4 + * @version 2.9.5 * @since 2.1.0 * @author WPFactory */ @@ -179,7 +179,7 @@ function handle_product_columns_style() { * * @see https://stackoverflow.com/a/4325608/1193038 * - * @version 2.3.5 + * @version 2.9.5 * @since 2.3.5 * * @param $value @@ -188,8 +188,12 @@ function handle_product_columns_style() { */ function sanitize_cog_meta( $value ) { if ( 'yes' === get_option( 'alg_wc_cog_products_sanitize_cog_meta', 'no' ) ) { - $value = str_replace( ',', '.', $value ); + $value = alg_wc_cog_sanitize_number( array( + 'number' => $value, + 'dots_and_commas_operation' => 'comma-to-dot' + ) ); } + return $value; } @@ -345,7 +349,7 @@ function render_product_columns( $column, $product_id ) { /** * get_product_cost. * - * @version 2.8.5 + * @version 2.9.5 * @since 1.0.0 */ function get_product_cost( $product_id, $args = null ) { @@ -365,11 +369,10 @@ function get_product_cost( $product_id, $args = null ) { ) { $cost = get_post_meta( $parent_id, '_alg_wc_cog_cost', true ); } - if ( 'comma-to-dot' === $dots_and_commas_operation ) { - $cost = str_replace( ',', '.', $cost ); - } elseif ( 'dot-to-comma' === $dots_and_commas_operation ) { - $cost = str_replace( '.', ',', (string) $cost ); - } + $cost = alg_wc_cog_sanitize_number( array( + 'number' => $cost, + 'dots_and_commas_operation' => $dots_and_commas_operation + ) ); $cost = $convert_to_number ? (float) $cost : $cost; return apply_filters( 'alg_wc_cog_get_product_cost', $cost, $product_id, isset( $parent_id ) ? $parent_id : null, $args ); } @@ -589,10 +592,32 @@ function update_product_price_by_profit( $args = array() ) { return true; } + /** + * update_variation_cost_from_parent. + * + * @version 2.9.5 + * @since 2.9.5 + * + * @param $args + * + * @return void + */ + function update_variation_cost_from_parent( $args = null ) { + $args = wp_parse_args( $args, array( + 'product_id' => '', + ) ); + $product_id = $args['product_id']; + $product = wc_get_product( $product_id ); + $parent_id = $product->get_parent_id(); + update_post_meta( $product_id, '_alg_wc_cog_cost', $this->get_product_cost( $parent_id, array( + 'check_parent_cost' => false + ) ) ); + } + /** * update_product_price. * - * @version 2.6.3 + * @version 2.9.5 * @since 2.5.1 * * @param null $args @@ -602,6 +627,7 @@ function update_product_price_by_profit( $args = array() ) { function update_product_cost_by_percentage( $args = null ) { $args = wp_parse_args( $args, array( 'product_id' => '', + 'costs_filter' => 'ignore_costs', // ignore_costs, products_without_costs, products_with_costs 'percentage' => 100, 'update_type' => 'costs_price', // costs_profit | costs_price 'update_variations' => true @@ -611,10 +637,13 @@ function update_product_cost_by_percentage( $args = null ) { $product = wc_get_product( $product_id ); $update_variations = $args['update_variations']; $update_type = $args['update_type']; + $costs_filter = $args['costs_filter']; if ( ! is_a( $product, 'WC_Product' ) ) { return false; } - update_post_meta( $product->get_id(), '_alg_wc_cog_cost', $this->calculate_product_cost_by_percentage( $product->get_price(), $percentage, $update_type ) ); + if ( $this->can_update_product_cost_based_on_costs_filter( $product_id, $costs_filter ) ) { + update_post_meta( $product->get_id(), '_alg_wc_cog_cost', $this->calculate_product_cost_by_percentage( $product->get_price(), $percentage, $update_type ) ); + } if ( $update_variations && $product->is_type( 'variable' ) && $product instanceof WC_Product_Variable @@ -625,12 +654,38 @@ function update_product_cost_by_percentage( $args = null ) { if ( empty( $variation_id ) || empty( $display_price ) ) { continue; } - update_post_meta( $variation_id, '_alg_wc_cog_cost', $this->calculate_product_cost_by_percentage( $display_price, $percentage, $update_type ) ); + if ( $this->can_update_product_cost_based_on_costs_filter( $variation_id, $costs_filter ) ) { + update_post_meta( $variation_id, '_alg_wc_cog_cost', $this->calculate_product_cost_by_percentage( $display_price, $percentage, $update_type ) ); + } } } return true; } + /** + * can_update_product_cost. + * + * @version 2.9.5 + * @since 2.9.5 + * + * @param $product_id + * @param $costs_filter + * + * @return bool + */ + function can_update_product_cost_based_on_costs_filter( $product_id, $costs_filter ): bool { + $can_update = false; + if ( + ( 'products_without_costs' === $costs_filter && empty( $this->get_product_cost( $product_id, array( 'check_parent_cost' => false ) ) ) ) || + ( 'products_with_costs' === $costs_filter && ! empty( $this->get_product_cost( $product_id, array( 'check_parent_cost' => false ) ) ) ) || + ( 'ignore_costs' === $costs_filter ) + ) { + $can_update = true; + } + + return $can_update; + } + /** * calculate_product_cost. * diff --git a/includes/settings/class-alg-wc-cog-settings-compatibility.php b/includes/settings/class-alg-wc-cog-settings-compatibility.php index 4c1b830..c8c03bc 100644 --- a/includes/settings/class-alg-wc-cog-settings-compatibility.php +++ b/includes/settings/class-alg-wc-cog-settings-compatibility.php @@ -91,9 +91,9 @@ function get_settings() { ); $curcy_multicurrency_opts = array( array( - 'title' => __( 'CURCY – Multi Currency for WooCommerce', 'cost-of-goods-for-woocommerce' ), + 'title' => __( 'CURCY - Multi Currency for WooCommerce', 'cost-of-goods-for-woocommerce' ), 'type' => 'title', - 'desc' => sprintf( __( 'Compatibility with %s plugin.', 'cost-of-goods-for-woocommerce' ), '' . __( 'CURCY – Multi Currency for WooCommerce', 'cost-of-goods-for-woocommerce' ) . '' ), + 'desc' => sprintf( __( 'Compatibility with %s plugin.', 'cost-of-goods-for-woocommerce' ), '' . __( 'CURCY - Multi Currency for WooCommerce', 'cost-of-goods-for-woocommerce' ) . '' ), 'id' => 'alg_wc_cog_compatibility_curcy_options', ), array( diff --git a/includes/tools/class-alg-wc-cog-bulk-edit-tool.php b/includes/tools/class-alg-wc-cog-bulk-edit-tool.php index 7b1b99f..5b360ee 100644 --- a/includes/tools/class-alg-wc-cog-bulk-edit-tool.php +++ b/includes/tools/class-alg-wc-cog-bulk-edit-tool.php @@ -2,7 +2,7 @@ /** * Cost of Goods for WooCommerce - Bulk Edit Tool Class. * - * @version 2.8.8 + * @version 2.9.5 * @since 1.2.0 * @author WPFactory */ @@ -24,21 +24,40 @@ class Alg_WC_Cost_of_Goods_Bulk_Edit_Tool { /** * Tool prices page's slug. + * + * @since 2.9.5 * * @var string */ private $page_slug_prices = 'bulk-edit-prices'; /** + * Update costs bkg process. + * + * @since 2.9.5 + * * @var Alg_WC_Cost_of_Goods_Update_Cost_Bkg_Process */ public $update_cost_bkg_process; /** + * Update prices bkg process. + * + * @since 2.9.5 + * * @var Alg_WC_Cost_of_Goods_Update_Price_Bkg_Process */ public $update_price_bkg_process; + /** + * Update variation costs bkg process. + * + * @since 2.9.5 + * + * @var Alg_WC_Cost_of_Goods_Update_Variation_Costs_Bkg_Process + */ + public $update_variation_costs_bkg_process; + /** * Constructor. * @@ -118,20 +137,22 @@ function remove_query_args() { /** * init_bkg_process. * - * @version 2.6.3 + * @version 2.9.5 * @since 2.5.1 */ function init_bkg_process() { require_once( alg_wc_cog()->plugin_path() . '/includes/background-process/class-alg-wc-cog-update-cost-bkg-process.php' ); require_once( alg_wc_cog()->plugin_path() . '/includes/background-process/class-alg-wc-cog-update-price-bkg-process.php' ); - $this->update_cost_bkg_process = new Alg_WC_Cost_of_Goods_Update_Cost_Bkg_Process(); - $this->update_price_bkg_process = new Alg_WC_Cost_of_Goods_Update_Price_Bkg_Process(); + require_once( alg_wc_cog()->plugin_path() . '/includes/background-process/class-alg-wc-cog-update-variation-costs-bkg-process.php' ); + $this->update_cost_bkg_process = new Alg_WC_Cost_of_Goods_Update_Cost_Bkg_Process(); + $this->update_price_bkg_process = new Alg_WC_Cost_of_Goods_Update_Price_Bkg_Process(); + $this->update_variation_costs_bkg_process = new Alg_WC_Cost_of_Goods_Update_Variation_Costs_Bkg_Process(); } /** * Update costs on Ajax for bulk edit tools. * - * @version 2.7.9 + * @version 2.9.5 * @since 2.5.1 */ function ajax_update_product_data() { @@ -144,16 +165,19 @@ function ajax_update_product_data() { if ( isset( $form_data["_nonce_{$update_type}_val"] ) && ! wp_verify_nonce( $form_data["_nonce_{$update_type}_val"], "_nonce_{$update_type}_action" ) ) { wp_send_json_error( esc_html__( 'Something went wrong! Please try again.', 'cost-of-goods-for-woocommerce' ) ); } - $percentage = isset( $form_data['percentage'] ) ? (float) sanitize_text_field( $form_data['percentage'] ) : ''; - $absolute_profit = isset( $form_data['absolute_profit'] ) ? (float) sanitize_text_field( $form_data['absolute_profit'] ) : ''; - $affected_field = isset( $form_data['affected_field'] ) ? $form_data['affected_field'] : 'regular_price'; - $rounding = isset( $form_data['rounding'] ) ? $form_data['rounding'] : ''; + $percentage = isset( $form_data['percentage'] ) ? (float) sanitize_text_field( $form_data['percentage'] ) : ''; + $absolute_profit = isset( $form_data['absolute_profit'] ) ? (float) sanitize_text_field( $form_data['absolute_profit'] ) : ''; + $affected_field = isset( $form_data['affected_field'] ) ? $form_data['affected_field'] : 'regular_price'; + $rounding = isset( $form_data['rounding'] ) ? $form_data['rounding'] : ''; + $costs_filter = sanitize_text_field( isset( $form_data['costs_filter'] ) ? $form_data['costs_filter'] : 'ignore_costs' ); + $update_variation_costs = filter_var( isset( $form_data['update_variation_costs'] ) ? $form_data['update_variation_costs'] : false, FILTER_VALIDATE_BOOLEAN ); + $empty_variation_costs_required = filter_var( isset( $form_data['empty_variation_costs_required'] ) ? $form_data['empty_variation_costs_required'] : false, FILTER_VALIDATE_BOOLEAN ); // Requirements. if ( empty( $update_type ) ) { wp_send_json_error( esc_html__( 'Some error has occurred. Please, try again.', 'cost-of-goods-for-woocommerce' ) ); } if ( 'update_costs' === $tool_type ) { - if ( empty( $percentage ) ) { + if ( isset( $form_data['percentage'] ) && empty( $percentage ) ) { wp_send_json_error( esc_html__( 'Invalid percentage.', 'cost-of-goods-for-woocommerce' ) ); } } else { @@ -171,6 +195,28 @@ function ajax_update_product_data() { 'fields' => 'ids', 'tax_query' => array() ); + if ( $update_variation_costs ) { + $query_args['post_type'] = 'product_variation'; + if ( $empty_variation_costs_required ) { + $query_args['meta_query'] = array( + 'relation' => 'OR', + array( + 'key' => '_alg_wc_cog_cost', + 'value' => 0, + 'compare' => '==', + ), + array( + 'key' => '_alg_wc_cog_cost', + 'value' => '', + 'compare' => '==', + ), + array( + 'key' => '_alg_wc_cog_cost', + 'compare' => 'NOT EXISTS', + ), + ); + } + } // Product Category. $product_category = isset( $form_data['product_category'] ) ? $form_data['product_category'] : ''; $product_category = is_array( $product_category ) ? $product_category : array(); @@ -197,101 +243,103 @@ function ajax_update_product_data() { } $posts = get_posts( $query_args ); $bkg_process_min_amount = get_option( 'alg_wc_cog_bkg_process_min_amount', 100 ); - $args = array( - 'products' => $posts, - 'bkg_process' => count( $posts ) >= $bkg_process_min_amount, - 'options' => array( - 'percentage' => $percentage, - 'absolute_profit' => $absolute_profit, - 'update_type' => $update_type, - 'affected_field' => $affected_field, - 'rounding' => $rounding, - ), - ); + $args = array( + 'products' => $posts, + 'bkg_process' => count( $posts ) >= $bkg_process_min_amount, + 'options' => array( + 'costs_filter' => $costs_filter, + 'percentage' => $percentage, + 'absolute_profit' => $absolute_profit, + 'update_type' => $update_type, + 'affected_field' => $affected_field, + 'rounding' => $rounding, + ), + ); // For bulk update - costs if( 'update_costs' === $tool_type ) { - wp_send_json_success( $this->bulk_update_costs( $args ) ); + if ( ! $update_variation_costs ) { + $bkg_process_progress_msg = __( 'Product costs are being updated via background processing.', 'cost-of-goods-for-woocommerce' ); + $bkg_process_progress_msg .= 'yes' === get_option( 'alg_wc_cog_bkg_process_send_email', 'yes' ) ? ' ' . sprintf( __( 'An email is going to be sent to %s when the task is completed.', 'cost-of-goods-for-woocommerce' ), get_option( 'alg_wc_cog_bkg_process_email_to', get_option( 'admin_email' ) ) ) : ''; + wp_send_json_success( $this->bulk_update_products( $args, array( + 'bkg_process_obj' => $this->update_cost_bkg_process, + 'success_msg' => __( 'Successfully updated product costs.', 'cost-of-goods-for-woocommerce' ), + 'bkg_process_progress_msg' => $bkg_process_progress_msg, + 'no_bkg_process_function' => 'update_product_cost_by_percentage', + ) ) ); + } else { + $bkg_process_progress_msg = __( 'Variation costs are being updated via background processing.', 'cost-of-goods-for-woocommerce' ); + $bkg_process_progress_msg .= 'yes' === get_option( 'alg_wc_cog_bkg_process_send_email', 'yes' ) ? ' ' . sprintf( __( 'An email is going to be sent to %s when the task is completed.', 'cost-of-goods-for-woocommerce' ), get_option( 'alg_wc_cog_bkg_process_email_to', get_option( 'admin_email' ) ) ) : ''; + wp_send_json_success( $this->bulk_update_products( $args, array( + 'bkg_process_obj' => $this->update_variation_costs_bkg_process, + 'success_msg' => __( 'Successfully updated variation costs.', 'cost-of-goods-for-woocommerce' ), + 'bkg_process_progress_msg' => $bkg_process_progress_msg, + 'no_bkg_process_function' => 'update_variation_cost_from_parent', + ) ) ); + } } // For bulk update - prices if( 'update_prices' === $tool_type ) { - wp_send_json_success( $this->bulk_update_prices( $args ) ); + $bkg_process_progress_msg = __( 'Product prices are being updated via background processing.', 'cost-of-goods-for-woocommerce' ); + $bkg_process_progress_msg .= 'yes' === get_option( 'alg_wc_cog_bkg_process_send_email', 'yes' ) ? ' ' . sprintf( __( 'An email is going to be sent to %s when the task is completed.', 'cost-of-goods-for-woocommerce' ), get_option( 'alg_wc_cog_bkg_process_email_to', get_option( 'admin_email' ) ) ) : ''; + wp_send_json_success( $this->bulk_update_products( $args, array( + 'bkg_process_obj' => $this->update_price_bkg_process, + 'success_msg' => __( 'Successfully updated product prices.', 'cost-of-goods-for-woocommerce' ), + 'bkg_process_progress_msg' => $bkg_process_progress_msg, + 'no_bkg_process_function' => 'update_product_cost_by_percentage', + ) ) ); } } /** - * Bulk update product prices - * - * @version 2.7.9 - * @since 2.6.1 - * - * @param array $args + * bulk_update_products. + * + * @version 2.9.5 + * @since 2.9.5 + * + * @param $update_args + * @param $function_args * * @return string */ - function bulk_update_prices( $args = array() ) { - $args = wp_parse_args( $args, array( + function bulk_update_products( $update_args = array(), $function_args = array() ) { + $update_args = wp_parse_args( $update_args, array( 'products' => array(), 'bkg_process' => false, 'options' => array(), ) ); - $products = $args['products']; - $bkg_process = $args['bkg_process']; - $options = $args['options']; - $message = __( 'Successfully updated product prices.', 'cost-of-goods-for-woocommerce' ); - if ( $bkg_process ) { - $message = __( 'Product prices are being updated via background processing.', 'cost-of-goods-for-woocommerce' ); - $message .= 'yes' === get_option( 'alg_wc_cog_bkg_process_send_email', 'yes' ) ? ' ' . sprintf( __( 'An email is going to be sent to %s when the task is completed.', 'cost-of-goods-for-woocommerce' ), get_option( 'alg_wc_cog_bkg_process_email_to', get_option( 'admin_email' ) ) ) : ''; - $this->update_price_bkg_process->cancel_process(); - } - foreach ( $products as $product_id ) { - $_options = wp_parse_args( $options, array( 'product_id' => $product_id ) ); - if ( $bkg_process ) { - $this->update_price_bkg_process->push_to_queue( $_options ); - } else { - alg_wc_cog()->core->products->update_product_price_by_profit( $_options ); - } - } - if ( $bkg_process ) { - $this->update_price_bkg_process->save()->dispatch(); - } - return esc_html( $message ); - } - - /** - * Bulk update product costs - * - * @version 2.6.1 - * @since 2.6.1 - * - * @param array $args - * - * @return string - */ - function bulk_update_costs( $args = array() ) { - $products = isset( $args['products'] ) ? (array) $args['products'] : array(); - $bkg_process = isset( $args['bkg_process'] ) && $args['bkg_process']; - $options = isset( $args['options'] ) ? (array) $args['options'] : array(); - $message = __( 'Successfully updated product costs.', 'cost-of-goods-for-woocommerce' ); - + $products = $update_args['products']; + $bkg_process = $update_args['bkg_process']; + $options = $update_args['options']; + $function_args = wp_parse_args( $function_args, array( + 'bkg_process_obj' => null, + 'success_msg' => __( 'Successfully updated product prices.', 'cost-of-goods-for-woocommerce' ), + 'bkg_process_progress_msg' => __( 'Product prices are being updated via background processing.', 'cost-of-goods-for-woocommerce' ), + 'no_bkg_process_function' => 'update_product_price_by_profit', + 'no_bkg_process_obj' => alg_wc_cog()->core->products + ) ); + $message = $function_args['success_msg']; + $bkg_process_obj = $function_args['bkg_process_obj']; + $no_bkg_process_function = $function_args['no_bkg_process_function']; + $no_bkg_process_obj = $function_args['no_bkg_process_obj']; if ( $bkg_process ) { - $message = __( 'Product costs are being updated via background processing.', 'cost-of-goods-for-woocommerce' ); - $message .= 'yes' === get_option( 'alg_wc_cog_bkg_process_send_email', 'yes' ) ? ' ' . sprintf( __( 'An email is going to be sent to %s when the task is completed.', 'cost-of-goods-for-woocommerce' ), get_option( 'alg_wc_cog_bkg_process_email_to', get_option( 'admin_email' ) ) ) : ''; - $this->update_cost_bkg_process->cancel_process(); + $message = $function_args['bkg_process_progress_msg']; + call_user_func( array( $bkg_process_obj, "cancel_process" ) ); } - foreach ( $products as $product_id ) { $_options = wp_parse_args( $options, array( 'product_id' => $product_id ) ); if ( $bkg_process ) { - $this->update_cost_bkg_process->push_to_queue( $_options ); + call_user_func_array( array( $bkg_process_obj, "push_to_queue" ), array( $_options ) ); } else { - alg_wc_cog()->core->products->update_product_cost_by_percentage( $_options ); + call_user_func_array( array( $no_bkg_process_obj, $no_bkg_process_function ), array( $_options ) ); } } - if ( $bkg_process ) { - $this->update_cost_bkg_process->save()->dispatch(); + call_user_func( array( $bkg_process_obj, "save" ) ); + call_user_func( array( $bkg_process_obj, "dispatch" ) ); } - + if ( empty( $products ) ) { + $message = __( 'It is not necessary to update any products.', 'cost-of-goods-for-woocommerce' ); + } return esc_html( $message ); } @@ -375,10 +423,40 @@ function display_bulk_edit_prices_profit() { + + + + + + + + + + + + + +

+ +

+ + + + + + +

+ +

+ + 'bulk-edit-costs ajax-submission', 'callback' => 'display_bulk_edit_costs_profit', ), + 'costs_variations' => array( + 'label' => esc_html__( 'Variations', 'cost-of-goods-for-woocommerce' ), + 'desc' => esc_html__( 'Set or update the variations to have the same cost value as their parent products.', 'cost-of-goods-for-woocommerce' ), + 'save_btn_bottom' => sprintf( '', esc_html__( 'Update Costs', 'cost-of-goods-for-woocommerce' ) ), + 'form_class' => 'bulk-edit-costs ajax-submission', + 'callback' => 'display_bulk_edit_variations', + ), 'prices_profit' => array( 'label' => esc_html__( 'By Profit', 'cost-of-goods-for-woocommerce' ), 'save_btn_top' => '', diff --git a/langs/cost-of-goods-for-woocommerce.pot b/langs/cost-of-goods-for-woocommerce.pot index b6a0f6f..11e5e9d 100644 --- a/langs/cost-of-goods-for-woocommerce.pot +++ b/langs/cost-of-goods-for-woocommerce.pot @@ -2,16 +2,16 @@ # This file is distributed under the GNU General Public License v3.0. msgid "" msgstr "" -"Project-Id-Version: cost-of-goods-for-woocommerce 2.9.3\n" +"Project-Id-Version: cost-of-goods-for-woocommerce 2.9.5\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/cost-of-goods-for-woocommerce\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2023-03-30T00:26:53+02:00\n" +"POT-Creation-Date: 2023-04-18T02:21:50+02:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"X-Generator: WP-CLI 2.4.0\n" +"X-Generator: WP-CLI 2.7.1\n" "X-Domain: cost-of-goods-for-woocommerce\n" #. Plugin Name of the plugin @@ -36,7 +36,7 @@ msgstr "" msgid "https://wpfactory.com" msgstr "" -#: cost-of-goods-for-woocommerce-pro.php:189 +#: cost-of-goods-for-woocommerce-pro.php:207 msgid "Go Pro" msgstr "" @@ -48,16 +48,16 @@ msgstr "" #: includes/analytics/class-alg-wc-cog-analytics-revenue.php:47 #: includes/analytics/class-alg-wc-cog-analytics-stock.php:88 #: includes/class-alg-wc-cog-orders-meta-boxes.php:145 -#: includes/class-alg-wc-cog-orders.php:382 -#: includes/class-alg-wc-cog-orders.php:462 +#: includes/class-alg-wc-cog-orders.php:605 +#: includes/class-alg-wc-cog-orders.php:685 #: includes/class-alg-wc-cog-products-add-stock.php:124 #: includes/class-alg-wc-cog-products-add-stock.php:141 -#: includes/class-alg-wc-cog-products.php:202 -#: includes/class-alg-wc-cog-products.php:213 -#: includes/class-alg-wc-cog-products.php:224 -#: includes/class-alg-wc-cog-products.php:281 -#: includes/pro/class-alg-wc-cog-pro.php:427 -#: includes/pro/class-alg-wc-cog-pro.php:784 +#: includes/class-alg-wc-cog-products.php:248 +#: includes/class-alg-wc-cog-products.php:259 +#: includes/class-alg-wc-cog-products.php:270 +#: includes/class-alg-wc-cog-products.php:327 +#: includes/pro/class-alg-wc-cog-pro.php:457 +#: includes/pro/class-alg-wc-cog-pro.php:814 #: includes/pro/reports/class-wc-report-alg-cog-stock.php:121 #: includes/tools/class-alg-wc-cog-wplist-bulk-edit-tool.php:350 #: includes/analytics/build/index.js:286 @@ -77,11 +77,11 @@ msgstr "" #: includes/analytics/class-alg-wc-cog-analytics-revenue.php:48 #: includes/analytics/class-alg-wc-cog-analytics-stock.php:89 #: includes/class-alg-wc-cog-orders-meta-boxes.php:146 -#: includes/class-alg-wc-cog-orders.php:383 -#: includes/class-alg-wc-cog-orders.php:472 -#: includes/class-alg-wc-cog-products.php:284 +#: includes/class-alg-wc-cog-orders.php:606 +#: includes/class-alg-wc-cog-orders.php:695 +#: includes/class-alg-wc-cog-products.php:330 #: includes/pro/reports/class-wc-report-alg-cog-stock.php:123 -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:343 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:391 #: includes/analytics/build/index.js:291 #: includes/analytics/build/index.js:420 #: includes/analytics/build/index.js:519 @@ -117,26 +117,30 @@ msgstr "" msgid "Cost of Goods for WooCommerce - Bulk update prices" msgstr "" -#: includes/class-alg-wc-cog-cost-inputs.php:38 +#: includes/background-process/class-alg-wc-cog-update-variation-costs-bkg-process.php:30 +msgid "Cost of Goods for WooCommerce - Bulk update variation costs" +msgstr "" + +#: includes/class-alg-wc-cog-cost-inputs.php:47 #: includes/settings/class-alg-wc-cog-settings-products.php:97 msgid "Cost (excl. tax) (%s)" msgstr "" -#: includes/class-alg-wc-cog-cost-inputs.php:77 -#: includes/class-alg-wc-cog-cost-inputs.php:132 +#: includes/class-alg-wc-cog-cost-inputs.php:86 +#: includes/class-alg-wc-cog-cost-inputs.php:141 #: includes/tools/class-alg-wc-cog-wplist-bulk-edit-tool.php:290 msgid "Profit: %s" msgstr "" -#: includes/class-alg-wc-cog-cost-inputs.php:78 -#: includes/class-alg-wc-cog-cost-inputs.php:133 +#: includes/class-alg-wc-cog-cost-inputs.php:87 +#: includes/class-alg-wc-cog-cost-inputs.php:142 #: includes/tools/class-alg-wc-cog-wplist-bulk-edit-tool.php:290 msgid "N/A" msgstr "" #: includes/class-alg-wc-cog-orders-meta-boxes.php:113 #: includes/class-alg-wc-cog-orders-meta-boxes.php:206 -#: includes/pro/class-alg-wc-cog-pro.php:776 +#: includes/pro/class-alg-wc-cog-pro.php:806 #: includes/settings/class-alg-wc-cog-settings-orders.php:407 #: includes/settings/class-alg-wc-cog-settings-products.php:235 #: includes/settings/class-alg-wc-settings-cog.php:24 @@ -221,51 +225,51 @@ msgstr "" msgid "fee" msgstr "" -#: includes/class-alg-wc-cog-orders.php:80 +#: includes/class-alg-wc-cog-orders.php:303 #: includes/settings/class-alg-wc-cog-settings-orders.php:180 msgid "You are selling below the cost of goods." msgstr "" -#: includes/class-alg-wc-cog-orders.php:194 +#: includes/class-alg-wc-cog-orders.php:417 #: includes/settings/class-alg-wc-cog-settings-orders.php:295 #: includes/settings/class-alg-wc-cog-settings-tools.php:360 msgid "Taxes to profit" msgstr "" -#: includes/class-alg-wc-cog-orders.php:232 +#: includes/class-alg-wc-cog-orders.php:455 #: includes/settings/class-alg-wc-cog-settings-orders.php:288 #: includes/settings/class-alg-wc-cog-settings-tools.php:359 msgid "Fees to profit" msgstr "" -#: includes/class-alg-wc-cog-orders.php:271 +#: includes/class-alg-wc-cog-orders.php:494 #: includes/settings/class-alg-wc-cog-settings-orders.php:274 #: includes/settings/class-alg-wc-cog-settings-tools.php:358 msgid "Shipping to profit" msgstr "" -#: includes/class-alg-wc-cog-orders.php:273 +#: includes/class-alg-wc-cog-orders.php:496 msgid "Shipping to profit (%s)" msgstr "" -#: includes/class-alg-wc-cog-orders.php:386 -#: includes/class-alg-wc-cog-orders.php:763 -#: includes/pro/class-alg-wc-cog-pro.php:593 -#: includes/pro/class-alg-wc-cog-pro.php:612 +#: includes/class-alg-wc-cog-orders.php:609 +#: includes/class-alg-wc-cog-orders.php:986 +#: includes/pro/class-alg-wc-cog-pro.php:623 +#: includes/pro/class-alg-wc-cog-pro.php:642 msgid "Cost of goods" msgstr "" -#: includes/class-alg-wc-cog-orders.php:475 +#: includes/class-alg-wc-cog-orders.php:698 #: includes/settings/class-alg-wc-cog-settings-orders.php:48 msgid "Profit percent" msgstr "" -#: includes/class-alg-wc-cog-orders.php:478 +#: includes/class-alg-wc-cog-orders.php:701 #: includes/settings/class-alg-wc-cog-settings-orders.php:48 msgid "Profit margin" msgstr "" -#: includes/class-alg-wc-cog-orders.php:799 +#: includes/class-alg-wc-cog-orders.php:1022 msgid "Handling Fee" msgstr "" @@ -279,7 +283,7 @@ msgid "\"Stock\" will be added to your inventory, and \"Cost\" will be used to c msgstr "" #: includes/class-alg-wc-cog-products-add-stock.php:68 -#: includes/pro/class-alg-wc-cog-pro.php:776 +#: includes/pro/class-alg-wc-cog-pro.php:806 #: includes/settings/class-alg-wc-cog-settings-products.php:226 #: includes/settings/class-alg-wc-cog-settings-products.php:233 #: includes/settings/class-alg-wc-cog-settings-products.php:235 @@ -288,7 +292,7 @@ msgstr "" #: includes/class-alg-wc-cog-products-add-stock.php:120 #: includes/class-alg-wc-cog-products-add-stock.php:140 -#: includes/pro/class-alg-wc-cog-pro.php:778 +#: includes/pro/class-alg-wc-cog-pro.php:808 #: includes/pro/reports/class-wc-report-alg-cog-stock.php:120 #: includes/settings/class-alg-wc-cog-settings-tools.php:133 #: includes/tools/class-alg-wc-cog-wplist-bulk-edit-tool.php:351 @@ -309,27 +313,27 @@ msgstr "" msgid "Cost archive" msgstr "" -#: includes/class-alg-wc-cog-products-cost-archive.php:137 +#: includes/class-alg-wc-cog-products-cost-archive.php:139 msgid "There isn't a cost archive for this product yet." msgstr "" -#: includes/class-alg-wc-cog-products-cost-archive.php:138 +#: includes/class-alg-wc-cog-products-cost-archive.php:140 msgid "Please, check if the option %s is enabled and then update the cost." msgstr "" -#: includes/class-alg-wc-cog-products-cost-archive.php:138 +#: includes/class-alg-wc-cog-products-cost-archive.php:140 msgid "Products > Cost archive > Save cost archive" msgstr "" -#: includes/class-alg-wc-cog-products-cost-archive.php:141 +#: includes/class-alg-wc-cog-products-cost-archive.php:143 msgid "Update date" msgstr "" -#: includes/class-alg-wc-cog-products-cost-archive.php:142 +#: includes/class-alg-wc-cog-products-cost-archive.php:144 msgid "Previous cost" msgstr "" -#: includes/class-alg-wc-cog-products-cost-archive.php:143 +#: includes/class-alg-wc-cog-products-cost-archive.php:145 msgid "New cost" msgstr "" @@ -348,31 +352,31 @@ msgstr "" msgid "Option(s) costs" msgstr "" -#: includes/pro/class-alg-wc-cog-pro.php:429 +#: includes/pro/class-alg-wc-cog-pro.php:459 msgid "- No change -" msgstr "" -#: includes/pro/class-alg-wc-cog-pro.php:538 +#: includes/pro/class-alg-wc-cog-pro.php:568 msgid "Orders cost and profit successfully recalculated." msgstr "" -#: includes/pro/class-alg-wc-cog-pro.php:545 +#: includes/pro/class-alg-wc-cog-pro.php:575 msgid "Orders cost and profit recalculating via background processing. You should receive an e-mail when it's complete if the \"Advanced > Background processing > Send email\" option is enabled." msgstr "" -#: includes/pro/class-alg-wc-cog-pro.php:548 +#: includes/pro/class-alg-wc-cog-pro.php:578 msgid "Something went wrong..." msgstr "" -#: includes/pro/class-alg-wc-cog-pro.php:666 +#: includes/pro/class-alg-wc-cog-pro.php:696 msgid "Cost of Goods reports are in %s and in %s." msgstr "" -#: includes/pro/class-alg-wc-cog-pro.php:668 +#: includes/pro/class-alg-wc-cog-pro.php:698 msgid "Reports > Orders > Cost of Goods" msgstr "" -#: includes/pro/class-alg-wc-cog-pro.php:670 +#: includes/pro/class-alg-wc-cog-pro.php:700 msgid "Reports > Stock > Cost of Goods" msgstr "" @@ -857,7 +861,7 @@ msgstr "" #: includes/settings/class-alg-wc-cog-settings-compatibility.php:94 #: includes/settings/class-alg-wc-cog-settings-compatibility.php:96 -msgid "CURCY – Multi Currency for WooCommerce" +msgid "CURCY - Multi Currency for WooCommerce" msgstr "" #: includes/settings/class-alg-wc-cog-settings-compatibility.php:96 @@ -2556,224 +2560,280 @@ msgstr "" msgid "Your settings have been reset." msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:145 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:166 msgid "Something went wrong! Please try again." msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:153 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:177 msgid "Some error has occurred. Please, try again." msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:157 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:181 msgid "Invalid percentage." msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:164 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:188 msgid "It's necessary to set the profit percentage or the absolute profit." msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:240 -msgid "Successfully updated product prices." +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:261 +msgid "Product costs are being updated via background processing." msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:242 -msgid "Product prices are being updated via background processing." +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:262 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:271 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:283 +msgid "An email is going to be sent to %s when the task is completed." msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:243 -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:278 -msgid "An email is going to be sent to %s when the task is completed." +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:265 +msgid "Successfully updated product costs." +msgstr "" + +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:270 +msgid "Variation costs are being updated via background processing." msgstr "" #: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:274 -msgid "Successfully updated product costs." +msgid "Successfully updated variation costs." msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:277 -msgid "Product costs are being updated via background processing." +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:282 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:316 +msgid "Product prices are being updated via background processing." msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:310 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:286 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:315 +msgid "Successfully updated product prices." +msgstr "" + +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:341 +msgid "It is not necessary to update any products." +msgstr "" + +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:358 msgid "Affected field" msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:313 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:361 msgid "Regular Price" msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:314 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:362 msgid "Sale Price" msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:317 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:365 msgid "The selected field will be updated on all the products." msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:322 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:370 msgid "Rounding" msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:325 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:373 msgid "Do not round" msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:326 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:374 msgid "Round" msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:327 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:375 msgid "Round up" msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:328 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:376 msgid "Round down" msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:333 -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:390 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:381 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:468 msgid "Profit percentage (%)" msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:337 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:385 msgid "Products prices will be set according to the profit percentage you'd like to achieve based on the current product costs." msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:347 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:395 msgid "Products prices will be set according to the absolute profit you'd like to achieve based on the current product costs." msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:353 -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:399 -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:449 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:401 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:477 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:540 msgid "Filter by category" msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:355 -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:401 -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:451 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:403 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:479 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:542 msgid "Search for a category…" msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:358 -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:407 -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:454 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:406 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:485 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:545 msgid "Select only the categories you want to edit. Leave it empty to update all products." msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:364 -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:413 -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:460 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:412 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:491 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:551 msgid "Filter by tag(s)" msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:366 -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:415 -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:462 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:414 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:493 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:553 msgid "Search for a tag…" msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:369 -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:418 -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:465 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:417 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:496 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:556 msgid "Select only the tag(s) you want to edit. Leave it empty to update all products." msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:394 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:440 +msgid "Undefined costs" +msgstr "" + +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:445 +msgid "Only update variations with empty costs or set as zero" +msgstr "" + +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:448 +msgid "If disabled, will update all variations, including the ones with costs already set." +msgstr "" + +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:472 msgid "Products costs will be set according to the profit percentage you'd like to achieve based on the current product prices." msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:439 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:502 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:562 +msgid "Filter by cost" +msgstr "" + +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:505 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:565 +msgid "Update products regardless of their current cost" +msgstr "" + +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:506 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:566 +msgid "Update products with no costs set, including zero or empty" +msgstr "" + +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:507 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:567 +msgid "Update products with costs already set" +msgstr "" + +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:530 msgid "Price percentage (%)" msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:443 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:534 msgid "Product costs will be defined from a percentage of product prices." msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:444 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:535 msgid "Most probably you should use a number between 0 and 100." msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:483 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:587 msgid "Search" msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:522 -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:714 -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:715 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:626 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:825 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:826 msgid "Bulk Edit Costs" msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:527 -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:724 -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:725 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:631 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:835 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:836 msgid "Bulk Edit Prices" msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:614 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:718 msgid "Manually" msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:617 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:721 msgid "Save" msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:619 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:723 msgid "Bulk edit products costs/prices/stock. Tools options can be set in \"Cost of Goods for WooCommerce\" plugin settings" msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:626 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:730 msgid "By Price" msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:627 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:731 msgid "Set the product costs from the product prices." msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:628 -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:636 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:732 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:740 msgid "Variations costs will also be updated accordingly." msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:629 -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:637 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:733 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:741 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:748 msgid "Update Costs" msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:634 -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:642 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:738 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:753 msgid "By Profit" msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:635 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:739 msgid "Set the product costs according to the profit you want to achieve." msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:645 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:746 +msgid "Variations" +msgstr "" + +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:747 +msgid "Set or update the variations to have the same cost value as their parent products." +msgstr "" + +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:756 msgid "Update prices" msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:647 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:758 msgid "Set the product prices according to the cost." msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:648 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:759 msgid "Variations prices will also be updated accordingly." msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:693 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:804 msgid "Items per page" msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:752 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:863 msgid "Are you really want to update?" msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:864 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:975 msgid "Data have been saved." msgstr "" -#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:884 +#: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:995 msgid "Sale price is higher than regular price: %s." msgstr "" diff --git a/readme.txt b/readme.txt index 221ca23..1e54971 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: wpcodefactory, karzin, kerbhavik, jaedm97, algoritmika, anbinder Tags: woocommerce, cost, cost of goods, cog, cost of goods sold, cogs, woo commerce Requires at least: 4.4 Tested up to: 6.2 -Stable tag: 2.9.4 +Stable tag: 2.9.5 License: GNU General Public License v3.0 License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -98,6 +98,11 @@ And then you can follow these steps: == Changelog == += 2.9.5 - 17/04/2023 = +* Fix - Products - Cost archive - New price column doesn't take decimals into account. +* Dev - Tools - Bulk edit costs - New option: Filter by cost, allowing to select only products with no costs or with costs. +* Dev - Tools - Bulk edit costs - New section: Variation - Set or update the variations to have the same cost value as their parent products. + = 2.9.4 - 04/04/2023 = * Fix - "Creation of dynamic property" PHP warning is being triggered on multiple locations. * Fix - Unsupported operand type: float / string on line 482 in `class-alg-wc-cog-products.php`.