Skip to content

Commit

Permalink
v2.9.6
Browse files Browse the repository at this point in the history
  • Loading branch information
pablo-sg-pacheco committed Apr 18, 2023
1 parent f830826 commit 7dc2333
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 19 deletions.
6 changes: 3 additions & 3 deletions cost-of-goods-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
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.5
Version: 2.9.6
Author: WPFactory
Author URI: https://wpfactory.com
Text Domain: cost-of-goods-for-woocommerce
Domain Path: /langs
Copyright: © 2023 WPFactory
WC tested up to: 7.5
WC tested up to: 7.6
License: GNU General Public License v3.0
License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
Expand Down Expand Up @@ -72,7 +72,7 @@ final class Alg_WC_Cost_of_Goods {
* @var string
* @since 1.0.0
*/
public $version = '2.9.5';
public $version = '2.9.6';

/**
* @var Alg_WC_Cost_of_Goods The single instance of the class
Expand Down
31 changes: 18 additions & 13 deletions includes/class-alg-wc-cog-products.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Cost of Goods for WooCommerce - Products Class.
*
* @version 2.9.5
* @version 2.9.6
* @since 2.1.0
* @author WPFactory
*/
Expand Down Expand Up @@ -451,24 +451,29 @@ function get_product_profit( $product_id ) {
/**
* get_product_profit_html.
*
* @version 2.3.9
* @version 2.9.6
* @since 1.0.0
*/
function get_product_profit_html( $product_id, $template = '%profit% (%profit_percent%)' ) {
$product = wc_get_product( $product_id );
if ( $product->is_type( 'variable' ) ) {
return $this->get_variable_product_html( $product_id, 'profit', $template );
} else {
if ( '' === ( $profit = $this->get_product_profit( $product_id ) ) ) {
return '';
if ( is_a( $product, 'WC_Product' ) ) {
if ( $product->is_type( 'variable' ) ) {
return $this->get_variable_product_html( $product_id, 'profit', $template );
} else {
$placeholders = array(
'%profit%' => wc_price( $profit ),
'%profit_percent%' => sprintf( '%0.2f%%', ( 0 != ( $cost = $this->get_product_cost( $product_id ) ) ? $profit / $cost * 100 : '' ) ),
'%profit_margin%' => sprintf( '%0.2f%%', ( 0 != ( $price = $this->get_product_price( $product ) ) ? $profit / $price * 100 : '' ) ),
);
return str_replace( array_keys( $placeholders ), $placeholders, $template );
if ( '' === ( $profit = $this->get_product_profit( $product_id ) ) ) {
return '';
} else {
$placeholders = array(
'%profit%' => wc_price( $profit ),
'%profit_percent%' => sprintf( '%0.2f%%', ( 0 != ( $cost = $this->get_product_cost( $product_id ) ) ? $profit / $cost * 100 : '' ) ),
'%profit_margin%' => sprintf( '%0.2f%%', ( 0 != ( $price = $this->get_product_price( $product ) ) ? $profit / $price * 100 : '' ) ),
);

return str_replace( array_keys( $placeholders ), $placeholders, $template );
}
}
} else {
return '';
}
}

Expand Down
4 changes: 2 additions & 2 deletions langs/cost-of-goods-for-woocommerce.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# This file is distributed under the GNU General Public License v3.0.
msgid ""
msgstr ""
"Project-Id-Version: cost-of-goods-for-woocommerce 2.9.5\n"
"Project-Id-Version: cost-of-goods-for-woocommerce 2.9.6\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/cost-of-goods-for-woocommerce\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2023-04-18T02:21:50+02:00\n"
"POT-Creation-Date: 2023-04-18T05:33:59+02:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.7.1\n"
"X-Domain: cost-of-goods-for-woocommerce\n"
Expand Down
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.5
Stable tag: 2.9.6
License: GNU General Public License v3.0
License URI: http://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -98,6 +98,10 @@ And then you can follow these steps:

== Changelog ==

= 2.9.6 - 18/04/2023 =
* Fix - `class-alg-wc-cog-products.php:456` - Call to a member function is_type() on bool.
* WC tested up to: 7.6.

= 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.
Expand Down

0 comments on commit 7dc2333

Please sign in to comment.