Skip to content

Commit

Permalink
v2.4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
pablo-sg-pacheco committed Aug 17, 2021
1 parent 6d8b23d commit f5b74de
Show file tree
Hide file tree
Showing 13 changed files with 355 additions and 272 deletions.
4 changes: 2 additions & 2 deletions cost-of-goods-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.4.5
Version: 2.4.6
Author: WPFactory
Author URI: https://wpfactory.com
Text Domain: cost-of-goods-for-woocommerce
Expand Down Expand Up @@ -63,7 +63,7 @@ final class Alg_WC_Cost_of_Goods {
* @var string
* @since 1.0.0
*/
public $version = '2.4.5';
public $version = '2.4.6';

/**
* @var Alg_WC_Cost_of_Goods The single instance of the class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Cost of Goods for WooCommerce - Background Process - Import
*
* @version 2.3.0
* @version 2.4.6
* @since 2.3.0
* @author WPFactory
*/
Expand Down Expand Up @@ -31,7 +31,7 @@ protected function get_action_label() {
}

/**
* @version 2.3.0
* @version 2.4.6
* @since 2.3.0
*
* @param mixed $item
Expand All @@ -40,7 +40,11 @@ protected function get_action_label() {
*/
protected function task( $item ) {
parent::task( $item );
alg_wc_cog()->core->import_tool->copy_product_meta( $item['id'], $item['from_key'], $item['to_key'] );
alg_wc_cog()->core->import_tool->copy_product_meta( array(
'product_id' => $item['id'],
'from_key' => $item['from_key'],
'to_key' => $item['to_key']
) );
return false;
}

Expand Down
6 changes: 3 additions & 3 deletions includes/class-alg-wc-cog-orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Cost of Goods for WooCommerce - Orders Class
*
* @version 2.4.5
* @version 2.4.6
* @since 2.1.0
* @author WPFactory
*/
Expand Down Expand Up @@ -633,7 +633,7 @@ function get_order_total_for_pecentage_fees( $order ) {
/**
* update_order_items_costs.
*
* @version 2.4.5
* @version 2.4.6
* @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`)
Expand Down Expand Up @@ -885,7 +885,7 @@ function update_order_items_costs( $order_id, $is_new_order, $is_no_costs_only =
// Fees: Order extra cost: per order
foreach ( $this->is_order_extra_cost_per_order as $fee_type => $is_enabled ) {
if ( $is_enabled && 0 !== ( (float) $fee = get_post_meta( $order_id, '_alg_wc_cog_order_' . $fee_type . '_fee', true ) ) ) {
$per_order_fees += $fee;
$per_order_fees += (float) $fee;
}
}
if ( 0 !== $per_order_fees ) {
Expand Down
86 changes: 3 additions & 83 deletions includes/settings/class-alg-wc-cog-settings-advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ function get_settings() {
),
array(
'title' => __( 'Send email', 'cost-of-goods-for-woocommerce' ),
'desc' => __( 'Enable', 'cost-of-goods-for-woocommerce' ),
'desc_tip' => __( 'Sends an email when a background processing is complete.', 'cost-of-goods-for-woocommerce' ),
'desc' => __( 'Send an email when a background processing is complete', 'cost-of-goods-for-woocommerce' ),
'id' => 'alg_wc_cog_bkg_process_send_email',
'default' => 'yes',
'type' => 'checkbox',
Expand All @@ -166,87 +165,8 @@ function get_settings() {
'type' => 'sectionend',
'id' => 'alg_wc_cog_advanced_bkg_process_options',
),
array(
'title' => __( 'Compatibility', 'cost-of-goods-for-woocommerce' ),
'type' => 'title',
'id' => 'alg_wc_cog_advanced_compatibility',
),
array(
'title' => __( 'WP All Import', 'cost-of-goods-for-woocommerce' ),
'desc' => sprintf( __( 'Enable compatibility with <a target="_blank" href="%s">WP All Import</a>', 'cost-of-goods-for-woocommerce' ), 'https://wordpress.org/plugins/wp-all-import/' ),
'desc_tip' => __( 'Makes fine adjustments when importing a cost value to <code>_alg_wc_cog_cost</code> meta using the <strong>WP All Import</strong> plugin.', 'cost-of-goods-for-woocommerce' ),
'id' => 'alg_wc_cog_wp_all_import',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'start',
'custom_attributes' => apply_filters( 'alg_wc_cog_settings', array( 'disabled' => 'disabled' ) ),
),
array(
'desc' => __( 'Convert to float', 'cost-of-goods-for-woocommerce' ),
'desc_tip' => __( 'Converts numbers using a comma for the decimal point and a dot as the thousand separator to float, like <code>1.723,07</code> to <code>1723.07</code>.', 'cost-of-goods-for-woocommerce' ),
'id' => 'alg_wc_cog_wp_all_import_convert_to_float',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Sanitize float number', 'cost-of-goods-for-woocommerce' ),
'desc_tip' => __( 'Removes all illegal characters from a float number, like currency values for example.', 'cost-of-goods-for-woocommerce' ),
'id' => 'alg_wc_cog_wp_all_import_sanitize_float',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
array(
'title' => __( 'WPC Product Bundles for WooCommerce', 'cost-of-goods-for-woocommerce' ),
'desc' => sprintf( __( 'Enable compatibility with <a target="_blank" href="%s">%s</a>', 'cost-of-goods-for-woocommerce' ), 'https://wordpress.org/plugins/woo-product-bundle/', __( 'WPC Product Bundles for WooCommerce', 'cost-of-goods-for-woocommerce' ) ),
'desc_tip' => __( 'Excludes Smart bundle product type from stock and orders report.', 'cost-of-goods-for-woocommerce' ),
'id' => 'alg_wc_cog_wpc_product_bundle_for_wc',
'default' => 'no',
'type' => 'checkbox',
'custom_attributes' => apply_filters( 'alg_wc_cog_settings', array( 'disabled' => 'disabled' ) ),
),
array(
'title' => __( 'Openpos - WooCommerce Point Of Sale(POS)', 'cost-of-goods-for-woocommerce' ),
'desc' => sprintf(
__( 'Enable compatibility with <a target="_blank" href="%s">%s</a> by <a href="%s" target="_blank">anhvnit</a> codenayon author', 'cost-of-goods-for-woocommerce' ),
'https://codecanyon.net/item/openpos-a-complete-pos-plugins-for-woocomerce/22613341', __( 'Openpos - WooCommerce Point Of Sale', 'cost-of-goods-for-woocommerce' ), 'https://codecanyon.net/user/anhvnit'
),
'desc_tip' => __( 'Manages POS orders on orders reports.', 'cost-of-goods-for-woocommerce' ),
'id' => 'alg_wc_cog_openpos_anhvnit',
'default' => 'no',
'type' => 'checkbox',
'custom_attributes' => apply_filters( 'alg_wc_cog_settings', array( 'disabled' => 'disabled' ) ),
),
array(
'desc' => __( 'Order types in reports.', 'cost-of-goods-for-woocommerce' ),
'desc_tip' => __( 'If empty will show common and openpos orders combined.', 'cost-of-goods-for-woocommerce' ),
'id' => 'alg_wc_cog_openpos_anhvnit_report_order_type',
'default' => array(),
'type' => 'multiselect',
'options' => array(
'common_orders' => __( 'Common orders', 'cost-of-goods-for-woocommerce' ),
'openpos_orders' => __( 'Openpos orders', 'cost-of-goods-for-woocommerce' )
),
'class' => 'chosen_select',
),
array(
'title' => __( 'Product Addons', 'cost-of-goods-for-woocommerce' ),
'desc' => sprintf(
__( 'Enable compatibility with <a target="_blank" href="%s">%s</a> by WooCommerce', 'cost-of-goods-for-woocommerce' ),
'https://woocommerce.com/products/product-add-ons/', __( 'Product Add-Ons', 'cost-of-goods-for-woocommerce' ) ),
'desc_tip' => ( $original_desc_tip = __( 'Adds costs fields for the addons and creates an order meta with addons costs.', 'cost-of-goods-for-woocommerce' ) . '<br />' .
sprintf( __( 'It\'s necessary to add %s on %s option.', 'cost-of-goods-for-woocommerce' ), '<code>' . '_alg_wc_cog_pao_costs' . '</code>', '<strong>' . __( 'Orders > Extra Costs: From Meta', 'cost-of-goods-for-woocommerce' ) . '</strong>' ) . '<br />' .
__( 'It\'s also necessary that addons do not change names once purchased.', 'cost-of-goods-for-woocommerce' ) ),
'id' => 'alg_wc_cog_product_addons',
'default' => 'no',
'type' => 'checkbox',
'custom_attributes' => apply_filters( 'alg_wc_cog_settings', array( 'disabled' => 'disabled' ) ),
),
array(
'type' => 'sectionend',
'id' => 'alg_wc_cog_advanced_compatibility',
),


);

return $advanced_settings;
Expand Down
126 changes: 126 additions & 0 deletions includes/settings/class-alg-wc-cog-settings-compatibility.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?php
/**
* Cost of Goods for WooCommerce - Compatibility Settings.
*
* @version 2.4.6
* @since 2.4.6
* @author WPFactory
*/

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

if ( ! class_exists( 'Alg_WC_Cost_of_Goods_Settings_Compatibility' ) ) :

class Alg_WC_Cost_of_Goods_Settings_Compatibility extends Alg_WC_Cost_of_Goods_Settings_Section {

/**
* Constructor.
*
* @version 2.4.6
* @since 2.4.6
*/
function __construct() {
$this->id = 'compatibility';
$this->desc = __( 'Compatibility', 'cost-of-goods-for-woocommerce' );
parent::__construct();
}

/**
* get_settings.
*
* @version 2.4.6
* @since 2.4.6
*/
function get_settings() {
$settings = array(
array(
'title' => __( 'Compatibility options', 'cost-of-goods-for-woocommerce' ),
'desc' => __( 'Compatibility with third party plugins or solutions.', 'emails-verification-for-woocommerce' ),
'type' => 'title',
'id' => 'alg_wc_cog_compatibility_options',
),
array(
'title' => __( 'WP All Import', 'cost-of-goods-for-woocommerce' ),
'desc' => sprintf( __( 'Enable compatibility with <a target="_blank" href="%s">WP All Import</a>', 'cost-of-goods-for-woocommerce' ), 'https://wordpress.org/plugins/wp-all-import/' ),
'desc_tip' => __( 'Makes fine adjustments when importing a cost value to <code>_alg_wc_cog_cost</code> meta using the <strong>WP All Import</strong> plugin.', 'cost-of-goods-for-woocommerce' ),
'id' => 'alg_wc_cog_wp_all_import',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'start',
'custom_attributes' => apply_filters( 'alg_wc_cog_settings', array( 'disabled' => 'disabled' ) ),
),
array(
'desc' => __( 'Convert to float', 'cost-of-goods-for-woocommerce' ),
'desc_tip' => __( 'Converts numbers using a comma for the decimal point and a dot as the thousand separator to float, like <code>1.723,07</code> to <code>1723.07</code>.', 'cost-of-goods-for-woocommerce' ),
'id' => 'alg_wc_cog_wp_all_import_convert_to_float',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => '',
),
array(
'desc' => __( 'Sanitize float number', 'cost-of-goods-for-woocommerce' ),
'desc_tip' => __( 'Removes all illegal characters from a float number, like currency values for example.', 'cost-of-goods-for-woocommerce' ),
'id' => 'alg_wc_cog_wp_all_import_sanitize_float',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
array(
'title' => __( 'WPC Product Bundles for WooCommerce', 'cost-of-goods-for-woocommerce' ),
'desc' => sprintf( __( 'Enable compatibility with <a target="_blank" href="%s">%s</a>', 'cost-of-goods-for-woocommerce' ), 'https://wordpress.org/plugins/woo-product-bundle/', __( 'WPC Product Bundles for WooCommerce', 'cost-of-goods-for-woocommerce' ) ),
'desc_tip' => __( 'Excludes Smart bundle product type from stock and orders report.', 'cost-of-goods-for-woocommerce' ),
'id' => 'alg_wc_cog_wpc_product_bundle_for_wc',
'default' => 'no',
'type' => 'checkbox',
'custom_attributes' => apply_filters( 'alg_wc_cog_settings', array( 'disabled' => 'disabled' ) ),
),
array(
'title' => __( 'Openpos - WooCommerce Point Of Sale(POS)', 'cost-of-goods-for-woocommerce' ),
'desc' => sprintf(
__( 'Enable compatibility with <a target="_blank" href="%s">%s</a> by <a href="%s" target="_blank">anhvnit</a> codenayon author', 'cost-of-goods-for-woocommerce' ),
'https://codecanyon.net/item/openpos-a-complete-pos-plugins-for-woocomerce/22613341', __( 'Openpos - WooCommerce Point Of Sale', 'cost-of-goods-for-woocommerce' ), 'https://codecanyon.net/user/anhvnit'
),
'desc_tip' => __( 'Manages POS orders on orders reports.', 'cost-of-goods-for-woocommerce' ),
'id' => 'alg_wc_cog_openpos_anhvnit',
'default' => 'no',
'type' => 'checkbox',
'custom_attributes' => apply_filters( 'alg_wc_cog_settings', array( 'disabled' => 'disabled' ) ),
),
array(
'desc' => __( 'Order types in reports.', 'cost-of-goods-for-woocommerce' ),
'desc_tip' => __( 'If empty will show common and openpos orders combined.', 'cost-of-goods-for-woocommerce' ),
'id' => 'alg_wc_cog_openpos_anhvnit_report_order_type',
'default' => array(),
'type' => 'multiselect',
'options' => array(
'common_orders' => __( 'Common orders', 'cost-of-goods-for-woocommerce' ),
'openpos_orders' => __( 'Openpos orders', 'cost-of-goods-for-woocommerce' )
),
'class' => 'chosen_select',
),
array(
'title' => __( 'Product Addons', 'cost-of-goods-for-woocommerce' ),
'desc' => sprintf(
__( 'Enable compatibility with <a target="_blank" href="%s">%s</a> by WooCommerce', 'cost-of-goods-for-woocommerce' ),
'https://woocommerce.com/products/product-add-ons/', __( 'Product Add-Ons', 'cost-of-goods-for-woocommerce' ) ),
'desc_tip' => ( $original_desc_tip = __( 'Adds costs fields for the addons and creates an order meta with addons costs.', 'cost-of-goods-for-woocommerce' ) . '<br />' .
sprintf( __( 'It\'s necessary to add %s on %s option.', 'cost-of-goods-for-woocommerce' ), '<code>' . '_alg_wc_cog_pao_costs' . '</code>', '<strong>' . __( 'Orders > Extra Costs: From Meta', 'cost-of-goods-for-woocommerce' ) . '</strong>' ) . '<br />' .
__( 'It\'s also necessary that addons do not change names once purchased.', 'cost-of-goods-for-woocommerce' ) ),
'id' => 'alg_wc_cog_product_addons',
'default' => 'no',
'type' => 'checkbox',
'custom_attributes' => apply_filters( 'alg_wc_cog_settings', array( 'disabled' => 'disabled' ) ),
),
array(
'type' => 'sectionend',
'id' => 'alg_wc_cog_compatibility_options',
),
);
return $settings;
}

}

endif;

return new Alg_WC_Cost_of_Goods_Settings_Compatibility();
2 changes: 1 addition & 1 deletion includes/settings/class-alg-wc-cog-settings-gateways.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Alg_WC_Cost_of_Goods_Settings_Gateways extends Alg_WC_Cost_of_Goods_Settin
*/
function __construct() {
$this->id = 'gateways';
$this->desc = __( 'Extra Costs', 'cost-of-goods-for-woocommerce' ) . ': ' . __( 'Payment Gateways', 'cost-of-goods-for-woocommerce' );
$this->desc = __( 'Payment Gateways', 'cost-of-goods-for-woocommerce' );
parent::__construct();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Alg_WC_Cost_of_Goods_Settings_Shipping_Classes extends Alg_WC_Cost_of_Good
*/
function __construct() {
$this->id = 'shipping_classes';
$this->desc = __( 'Extra Costs', 'cost-of-goods-for-woocommerce' ) . ': ' . __( 'Shipping classes', 'cost-of-goods-for-woocommerce' );
$this->desc = __( 'Shipping classes', 'cost-of-goods-for-woocommerce' );
parent::__construct();
}

Expand Down
2 changes: 1 addition & 1 deletion includes/settings/class-alg-wc-cog-settings-shipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Alg_WC_Cost_of_Goods_Settings_Shipping extends Alg_WC_Cost_of_Goods_Settin
*/
function __construct() {
$this->id = 'shipping';
$this->desc = __( 'Extra Costs', 'cost-of-goods-for-woocommerce' ) . ': ' . __( 'Shipping Methods', 'cost-of-goods-for-woocommerce' );
$this->desc = __( 'Shipping Methods', 'cost-of-goods-for-woocommerce' );
parent::__construct();
}

Expand Down
26 changes: 15 additions & 11 deletions includes/settings/class-alg-wc-cog-settings-tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Cost of Goods for WooCommerce - Tools Section Settings
*
* @version 2.4.5
* @version 2.4.6
* @since 1.4.0
* @author WPFactory
*/
Expand All @@ -29,7 +29,7 @@ function __construct() {
/**
* get_settings.
*
* @version 2.4.5
* @version 2.4.6
* @since 1.4.0
* @todo [later] better descriptions
* @todo [maybe] add "PHP time limit" option, i.e. `set_time_limit()`
Expand Down Expand Up @@ -99,9 +99,9 @@ function get_settings() {
array(
'title' => __( 'Product Import Costs Tool', 'cost-of-goods-for-woocommerce' ),
'type' => 'title',
'desc' => sprintf( __( 'A tool used to replace the cost meta %s value by some other meta value.', 'cost-of-goods-for-woocommerce' ), '<code>_alg_wc_cog_cost</code>' ) .
'<br />' .
sprintf( __( 'The Import tool is in %s.', 'cost-of-goods-for-woocommerce' ),
'desc' => __( 'A tool created with the purpose of importing the cost meta from another plugin by replacing the cost meta.', 'cost-of-goods-for-woocommerce' ) . '<br />' .
__( 'If you wish, you can use it on the opposite way by swapping the from and to keys.', 'cost-of-goods-for-woocommerce' ) . ' ' . __( 'You can also use it with any other metas.', 'cost-of-goods-for-woocommerce' ) . '<br />' .
sprintf( __( 'You can find the Import tool at %s.', 'cost-of-goods-for-woocommerce' ),
'<a href="' . admin_url( 'tools.php?page=import-costs' ) . '">' . __( 'Tools > Import Costs', 'cost-of-goods-for-woocommerce' ) . '</a>' ),
'id' => 'alg_wc_cog_import_tool_options',
),
Expand All @@ -112,26 +112,30 @@ function get_settings() {
'id' => 'alg_wc_cog_tool_key',
'default' => '_wc_cog_cost',
),
array(
'title' => __( 'Meta key replaced', 'cost-of-goods-for-woocommerce' ),
'type' => 'text',
'id' => 'alg_wc_cog_tool_key_to',
'default' => '_alg_wc_cog_cost',
),
array(
'title' => __( 'Check if key exists', 'cost-of-goods-for-woocommerce' ),
'type' => 'checkbox',
'desc' => __( 'Enable', 'cost-of-goods-for-woocommerce' ),
'desc_tip' => __( 'Only tries to replace the cost meta if the key exists.', 'cost-of-goods-for-woocommerce' ),
'desc' => __( 'Replace the meta value only if the from key exists', 'cost-of-goods-for-woocommerce' ),
'id' => 'alg_wc_cog_import_tool_check_key',
'default' => 'yes',
),
array(
'title' => __( 'Check key value', 'cost-of-goods-for-woocommerce' ),
'type' => 'checkbox',
'desc' => __( 'Enable', 'cost-of-goods-for-woocommerce' ),
'desc_tip' => __( 'Only tries to replace the cost meta value if the key value is not empty, null or zero.', 'cost-of-goods-for-woocommerce' ),
'desc' => __( 'Replace the meta value only if the from key value is not empty, null or zero', 'cost-of-goods-for-woocommerce' ),
'id' => 'alg_wc_cog_import_tool_check_value',
'default' => 'yes',
),
array(
'title' => __( 'Display table', 'cost-of-goods-for-woocommerce' ),
'title' => __( 'Table', 'cost-of-goods-for-woocommerce' ),
'type' => 'checkbox',
'desc' => __( 'Enable', 'cost-of-goods-for-woocommerce' ),
'desc' => __( 'Display a table at the import page', 'cost-of-goods-for-woocommerce' ),
'desc_tip' => __( 'If you have problems accessing the "Import Costs" page try to disable this option.', 'cost-of-goods-for-woocommerce' ),
'id' => 'alg_wc_cog_import_tool_display_table',
'default' => 'no',
Expand Down
Loading

0 comments on commit f5b74de

Please sign in to comment.