Skip to content

Commit

Permalink
Merge pull request #58 from newfold-labs/PRESS4-502
Browse files Browse the repository at this point in the history
Fixed the deprecated warning from wp-module-data module
  • Loading branch information
circlecube authored Mar 13, 2024
2 parents e5b234c + 1b1b0dd commit 8dd8018
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions includes/Listeners/Commerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public function register_hooks() {
/**
* On Payment, send data to Hiive
*
* @param int $order_id
* @param \WC_Order $order
* @param int $order_id the order id
* @param \WC_Order $order the order
*
* @return void
*/
Expand All @@ -60,7 +60,9 @@ public function products_count( $data ) {
if ( ! isset( $data['meta'] ) ) {
$data['meta'] = array();
}
$data['meta']['products_count'] = (int) wp_count_posts( 'product' )->publish;
if ( isset( wp_count_posts( 'product' )->publish ) ) {
$data['meta']['products_count'] = (int) wp_count_posts( 'product' )->publish;
}

return $data;
}
Expand All @@ -76,7 +78,9 @@ public function orders_count( $data ) {
if ( ! isset( $data['meta'] ) ) {
$data['meta'] = array();
}
$data['meta']['orders_count'] = (int) wp_count_posts( 'shop_order' )->publish;
if ( isset( wp_count_posts( 'shop_order' )->publish ) ) {
$data['meta']['orders_count'] = (int) wp_count_posts( 'shop_order' )->publish;
}

return $data;
}
Expand Down Expand Up @@ -124,7 +128,7 @@ public function checkout_views() {
/**
* Thank you page, send data to Hiive
*
* @param int $order_id
* @param int $order_id the order id
*
* @return void
*/
Expand All @@ -151,8 +155,8 @@ public function thank_you_page( $order_id ) {
/**
* Razorpay connected
*
* @param string $new_option New value of the razorpay_data_production option
* @param string $old_option Old value of the razorpay_data_production option
* @param string $new_option New value of the razorpay_data_production option
* @param string $old_option Old value of the razorpay_data_production option
*
* @return string The new option value
*/
Expand All @@ -177,8 +181,8 @@ public function razorpay_connection( $new_option, $old_option ) {
/**
* Shippo connected
*
* @param string $new_option New value of the shippo_data option
* @param string $old_option Old value of the shippo_data option
* @param string $new_option New value of the shippo_data option
* @param string $old_option Old value of the shippo_data option
*
* @return string The new option value
*/
Expand All @@ -203,8 +207,8 @@ public function shippo_connection( $new_option, $old_option ) {
/**
* Stripe connected
*
* @param string $new_option New value of the stripe_data_production option
* @param string $old_option Old value of the stripe_data_production option
* @param string $new_option New value of the stripe_data_production option
* @param string $old_option Old value of the stripe_data_production option
*
* @return string The new option value
*/
Expand All @@ -229,8 +233,8 @@ public function stripe_connection( $new_option, $old_option ) {
/**
* PayPal connected
*
* @param string $new_option New value of the yith_ppwc_merchant_data_production option
* @param string $old_option Old value of the yith_ppwc_merchant_data_production option
* @param string $new_option New value of the yith_ppwc_merchant_data_production option
* @param string $old_option Old value of the yith_ppwc_merchant_data_production option
*
* @return string The new option value
*/
Expand All @@ -255,13 +259,13 @@ public function paypal_connection( $new_option, $old_option ) {
/**
* Ecomdash connection, send data to Hiive
*
* @param string $new_option New value of the update_option_ewc4wp_sso_account_status option
* @param string $old_option Old value of the update_option_ewc4wp_sso_account_status option
* @param string $new_option New value of the update_option_ewc4wp_sso_account_status option
* @param string $old_option Old value of the update_option_ewc4wp_sso_account_status option
*
* @return string The new option value
*/
public function ecomdash_connected( $new_option, $old_option ) {
if ( $new_option !== $old_option && ! empty( $new_option ) && $new_option === 'connected' ) {
if ( $new_option !== $old_option && ! empty( $new_option ) && 'connected' === $new_option ) {
$url = is_ssl() ? 'https://' : 'http://';
$url .= $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$data = array(
Expand All @@ -278,8 +282,8 @@ public function ecomdash_connected( $new_option, $old_option ) {
/**
* Product added, send data to Hiive
*
* @param string $product_id id of post which is being savedPost ObjectOld value of the yith_ppwc_merchant_data_production option
* @param WP_POST $product details of the product
* @param string $product_id id of post which is being savedPost ObjectOld value of the yith_ppwc_merchant_data_production option
* @param WP_POST $product details of the product
* @return void
*/
public function product_created_or_updated( $product_id, $product ) {
Expand All @@ -299,17 +303,17 @@ public function product_created_or_updated( $product_id, $product ) {
* HPOS (High Performance Order Storage) is enabled
* Send data to hiive
* @param string $old_value Old value of woocommerce_custom_orders_table_enabled
* @param string $new_value New value of woocommerce_custom_orders_table_enabled
* @param option name of the option being updated
* @param string $old_value Old value of woocommerce_custom_orders_table_enabled
* @param string $new_value New value of woocommerce_custom_orders_table_enabled
* @param string $option name of the option being updated
* @return void
*/
public function woocommerce_hpos_enabled( $old_value, $new_value, $option ) {
if ( $new_value !== $old_value && ! empty( $new_value ) ) {
$url = is_ssl() ? 'https://' : 'http://';
$url .= $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$type = ( $new_value === 'yes' ) ? 'hpos' : 'legacy';
$type = ( 'yes' === $new_value ) ? 'hpos' : 'legacy';

$data = array(
'label_key' => $option,
Expand Down

0 comments on commit 8dd8018

Please sign in to comment.