Skip to content

Commit d2a6018

Browse files
fix: do not show leaderboard preference twice
1 parent 81ee4c7 commit d2a6018

File tree

1 file changed

+3
-29
lines changed

1 file changed

+3
-29
lines changed

includes/class-wcdp_leaderboard.php

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,8 @@ public function __construct()
3131
//Save the value of the WooCommerce checkout checkbox
3232
add_action('woocommerce_checkout_create_order', array($this, 'save_anonymous_donation_checkbox'));
3333

34-
//Display the value of the WooCommerce checkout checkbox to the user
35-
add_action('woocommerce_order_details_after_customer_details', array($this, 'display_anonymous_donation_checkbox_in_order_details'));
36-
37-
// Display the value in My Account order details page too
38-
add_action('woocommerce_view_order', array($this, 'display_anonymous_donation_checkbox_in_account_order_details'), 20);
34+
// Display the value of the WooCommerce checkout checkbox to the user
35+
add_action('woocommerce_order_details_after_customer_details', array($this, 'display_anonymous_donation_checkbox_in_account_order_details'), 20);
3936
}
4037

4138
// Clear donable products cache when product meta is updated
@@ -769,29 +766,6 @@ public function save_anonymous_donation_checkbox($order)
769766
}
770767
}
771768

772-
/**
773-
* Display the value of the anonymous checkbox to the user
774-
* @param $order
775-
* @return void
776-
*/
777-
public function display_anonymous_donation_checkbox_in_order_details($order)
778-
{
779-
if (!WCDP_Form::order_contains_donation($order)) {
780-
return;
781-
}
782-
783-
$checkbox_value = $order->get_meta('wcdp_checkout_checkbox');
784-
785-
if ($checkbox_value === null || $checkbox_value === '')
786-
return;
787-
788-
echo wp_kses_post(sprintf(
789-
'<p><strong>%s:</strong> %s</p>',
790-
esc_html(get_option("wcdp_checkout_checkbox_text", __('Do not show my name in the leaderboard', 'wc-donation-platform'))),
791-
esc_html($checkbox_value === "yes" ? __('Yes', 'wc-donation-platform') : __('No', 'wc-donation-platform'))
792-
));
793-
}
794-
795769
/**
796770
* Clear donable products cache when _donable meta is updated
797771
* @param int $meta_id
@@ -829,7 +803,7 @@ public function display_anonymous_donation_checkbox_in_account_order_details($or
829803
return;
830804

831805
echo wp_kses_post(sprintf(
832-
'<section class="woocommerce-order-leaderboard-preference"><h2>%s</h2><p><strong>%s:</strong> %s</p></section>',
806+
'<section class="woocommerce-order-leaderboard-preference"><h2 style="margin: 1em 0 0;">%s</h2><p><strong>%s:</strong> %s</p></section>',
833807
esc_html__('Leaderboard Preference', 'wc-donation-platform'),
834808
esc_html(get_option("wcdp_checkout_checkbox_text", __('Do not show my name in the leaderboard', 'wc-donation-platform'))),
835809
esc_html($checkbox_value === "yes" ? __('Yes', 'wc-donation-platform') : __('No', 'wc-donation-platform'))

0 commit comments

Comments
 (0)