| @@ -150,9 +150,8 @@ | ||
| 150 | 150 | <?php |
| 151 | 151 | $hookData = [ |
| 152 | 152 | 'cart' => $this->cart |
| 153 | 153 | ]; |
| 154 | - do_action_deprecated('fluent_cart/afrer_checkout_page_start', [$hookData], '1.3.16', 'fluent_cart/after_checkout_page_start', 'Use fluent_cart/after_checkout_page_start instead of fluent_cart/afrer_checkout_page_start.'); | |
| 155 | 154 | do_action('fluent_cart/after_checkout_page_start', $hookData); |
| 156 | 155 | } |
| 157 | 156 | |
| 158 | 157 | public function renderNotices() |
| @@ -310,8 +309,13 @@ | ||
| 310 | 309 | if (!CheckoutFieldsSchema::hasAnyBusinessFields()) { |
| 311 | 310 | return; |
| 312 | 311 | } |
| 313 | 312 | |
| 313 | + if (CheckoutFieldsSchema::isB2BOnlyMode()) { | |
| 314 | + $this->renderBusinessDetailsSection(true); | |
| 315 | + return; | |
| 316 | + } | |
| 317 | + | |
| 314 | 318 | $isB2B = Arr::get($this->cart->checkout_data, 'form_data.is_business', 'no') === 'yes'; |
| 315 | 319 | |
| 316 | 320 | $hasBusinessSection = CheckoutFieldsSchema::isCompanyNameEnabled() |
| 317 | 321 | || CheckoutFieldsSchema::isLegalRegistrationIdEnabled() |
| @@ -771,8 +775,9 @@ | ||
| 771 | 775 | } |
| 772 | 776 | |
| 773 | 777 | $selectedPaymentMethod = Arr::get($this->cart->checkout_data, 'form_data._fct_pay_method', ''); |
| 774 | 778 | $activePaymentMethods = PaymentMethods::getActiveMethodInstance($this->cart); |
| 779 | + $hadActiveMethods = !empty($activePaymentMethods); | |
| 775 | 780 | |
| 776 | 781 | $activePaymentMethods = apply_filters('fluent_cart/checkout_active_payment_methods', $activePaymentMethods, [ |
| 777 | 782 | 'cart' => $this->cart |
| 778 | 783 | ]); |
| @@ -777,11 +782,28 @@ | ||
| 777 | 782 | 'cart' => $this->cart |
| 778 | 783 | ]); |
| 779 | 784 | |
| 780 | 785 | if (!$selectedPaymentMethod && !empty($activePaymentMethods)) { |
| 781 | - $selectedPaymentMethod = $activePaymentMethods[0] ? $activePaymentMethods[0]->getMeta('route') : ''; | |
| 786 | + // reset() not [0] — the filter above may return a non-zero-indexed array. | |
| 787 | + $firstMethod = reset($activePaymentMethods); | |
| 788 | + $selectedPaymentMethod = $firstMethod ? $firstMethod->getMeta('route') : ''; | |
| 782 | 789 | } |
| 783 | 790 | |
| 791 | + /** | |
| 792 | + * The payment method rendered as checked. An add-on that renders its own | |
| 793 | + * selector outside this list (e.g. saved payment methods) returns a route | |
| 794 | + * that is not in the list, so no gateway here is checked — the page then | |
| 795 | + * arrives with the add-on's choice already selected instead of a gateway | |
| 796 | + * being checked first and switched over by JS after load. | |
| 797 | + * | |
| 798 | + * @param string $selectedPaymentMethod | |
| 799 | + * @param array $context ['cart' => Cart, 'payment_methods' => array] | |
| 800 | + */ | |
| 801 | + $selectedPaymentMethod = (string) apply_filters('fluent_cart/checkout/selected_payment_method', $selectedPaymentMethod, [ | |
| 802 | + 'cart' => $this->cart, | |
| 803 | + 'payment_methods' => $activePaymentMethods | |
| 804 | + ]); | |
| 805 | + | |
| 784 | 806 | $checkoutMethodStyle = $this->storeSettings->get('checkout_method_style', 'logo'); |
| 785 | 807 | |
| 786 | 808 | ?> |
| 787 | 809 | <div id="fluent_payment_methods" class="fluent_payment_methods"> |
| @@ -808,9 +830,13 @@ | ||
| 808 | 830 | ?> |
| 809 | 831 | <?php endforeach; ?> |
| 810 | 832 | <?php else: ?> |
| 811 | 833 | <?php |
| 812 | - $emptyText = esc_html__('No Payment method is activated for this site yet.', 'fluent-cart'); | |
| 834 | + if ($hadActiveMethods) { | |
| 835 | + $emptyText = esc_html__('None of the available payment methods can process this order. Please contact the store.', 'fluent-cart'); | |
| 836 | + } else { | |
| 837 | + $emptyText = esc_html__('No Payment method is activated for this site yet.', 'fluent-cart'); | |
| 838 | + } | |
| 813 | 839 | if (current_user_can('manage_options')) { |
| 814 | 840 | $emptyText .= '<a href="' . esc_url(URL::getDashboardUrl('settings/payments')) . '" target="_blank">' . esc_html__('Activate from settings.', 'fluent-cart') . '</a>'; |
| 815 | 841 | } |
| 816 | 842 | echo '<div class="fct-empty-state">' . wp_kses_post($emptyText) . '</div>'; |
| @@ -922,9 +948,9 @@ | ||
| 922 | 948 | 'route' => $route, |
| 923 | 949 | 'method_title' => $methodTitle, |
| 924 | 950 | 'method_style' => $methodStyle, |
| 925 | 951 | ]; |
| 926 | - $paymentMethodClass = apply_filters_deprecated('fluent_cart_payment_method_list_class', ['', $pmContext], '1.3.16', 'fluent_cart/payment_method_list_class', 'Use fluent_cart/payment_method_list_class instead of fluent_cart_payment_method_list_class.'); | |
| 952 | + $paymentMethodClass = ''; | |
| 927 | 953 | $paymentMethodClass = apply_filters('fluent_cart/payment_method_list_class', $paymentMethodClass, $pmContext); |
| 928 | 954 | |
| 929 | 955 | ?> |
| 930 | 956 | <div class="<?php echo "fluent-cart-checkout_embed_payment_container fluent-cart-checkout_embed_payment_container_" . esc_attr($route . ' ' . $paymentMethodClass); ?>" |