Skip to content

Commit

Permalink
fix: melhoria na mensagem de notificação das taxas
Browse files Browse the repository at this point in the history
  • Loading branch information
lucastgama committed Aug 14, 2024
1 parent 5c2fdf0 commit 46e453d
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/utils/FrontendFilesLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,27 +111,34 @@ public function enqueue_inputmask_scripts()
');
}

public function check_for_subscription_in_order() {
public function check_for_subscription_in_order()
{
global $post;

if ($post->post_type === 'shop_order' || $post->post_type === 'shop_subscription') {
if ($this->is_shop_order_or_subscription($post)) {
$order = wc_get_order($post->ID);
$has_subscription = false;
$subscriptions_product = new WC_Subscriptions_Product();

foreach ($order->get_items() as $item_id => $item) {
foreach ($order->get_items() as $item) {
if ($subscriptions_product->is_subscription($item->get_product())) {
$has_subscription = true;
break;
}
}

wp_register_script('notification-js', plugins_url('/assets/js/notification.js', plugin_dir_path(__FILE__)), array('jquery'), VINDI_VERSION, true);

$dir_path = plugins_url('/assets/js/notification.js', plugin_dir_path(__FILE__));
wp_register_script('notification-js', $dir_path, array('jquery'), VINDI_VERSION, true);
wp_enqueue_script('notification-js');

wp_localize_script('notification-js', 'orderData', array(
'hasSubscription' => $has_subscription
));
}
}

private function is_shop_order_or_subscription($post)
{
return $post->post_type === 'shop_order' || $post->post_type === 'shop_subscription';
}
}

0 comments on commit 46e453d

Please sign in to comment.