| @@ -4,8 +4,9 @@ | ||
| 4 | 4 | |
| 5 | 5 | use FluentCart\Api\StoreSettings; |
| 6 | 6 | use FluentCart\App\App; |
| 7 | 7 | use FluentCart\App\Helpers\Helper; |
| 8 | +use FluentCart\App\Helpers\Status; | |
| 8 | 9 | use FluentCart\App\Modules\Tax\TaxModule; |
| 9 | 10 | use FluentCart\App\Modules\Templating\AssetLoader; |
| 10 | 11 | use FluentCart\App\Vite; |
| 11 | 12 | use FluentCart\Framework\Support\Arr; |
| @@ -105,47 +106,79 @@ | ||
| 105 | 106 | ]); |
| 106 | 107 | } |
| 107 | 108 | } |
| 108 | 109 | |
| 110 | + protected function getHeaderState() | |
| 111 | + { | |
| 112 | + $order = Arr::get($this->config, 'order', null); | |
| 113 | + $status = $order ? $order->payment_status : ''; | |
| 114 | + | |
| 115 | + if ($status === Status::PAYMENT_REFUNDED) { | |
| 116 | + return 'refunded'; | |
| 117 | + } | |
| 118 | + if ($status === Status::PAYMENT_FAILED) { | |
| 119 | + return 'failed'; | |
| 120 | + } | |
| 121 | + if (in_array($status, [Status::PAYMENT_PAID, Status::PAYMENT_PARTIALLY_REFUNDED], true)) { | |
| 122 | + return 'success'; | |
| 123 | + } | |
| 124 | + | |
| 125 | + return 'pending'; | |
| 126 | + } | |
| 127 | + | |
| 109 | 128 | public function renderHeader() |
| 110 | 129 | { |
| 111 | - $bgColor = '#d4edda'; | |
| 112 | - $titleColor = '#155724'; | |
| 113 | - $iconBg = '#155724bd'; | |
| 130 | + $state = $this->getHeaderState(); | |
| 114 | 131 | |
| 115 | - $order = Arr::get($this->config, 'order', null); | |
| 132 | + $styles = [ | |
| 133 | + 'success' => ['bg' => '#d4edda', 'title' => '#155724', 'iconBg' => '#155724bd'], | |
| 134 | + 'pending' => ['bg' => '#fff3cd', 'title' => '#856404', 'iconBg' => '#856404bd'], | |
| 135 | + 'failed' => ['bg' => '#f8d7da', 'title' => '#721c24', 'iconBg' => '#721c24bd'], | |
| 136 | + 'refunded' => ['bg' => '#e2e3e5', 'title' => '#383d41', 'iconBg' => '#383d41bd'], | |
| 137 | + ]; | |
| 116 | 138 | |
| 117 | - if ($order->payment_status !== 'paid') { | |
| 118 | - $bgColor = '#fff3cd'; | |
| 119 | - $titleColor = '#856404'; | |
| 120 | - $iconBg = '#856404bd'; | |
| 121 | - } | |
| 139 | + $titles = [ | |
| 140 | + 'success' => __('Purchase Successful!', 'fluent-cart'), | |
| 141 | + 'pending' => __('Payment Pending!', 'fluent-cart'), | |
| 142 | + 'failed' => __('Payment Failed', 'fluent-cart'), | |
| 143 | + 'refunded' => __('Order Refunded', 'fluent-cart'), | |
| 144 | + ]; | |
| 145 | + | |
| 146 | + $bgColor = $styles[$state]['bg']; | |
| 147 | + $titleColor = $styles[$state]['title']; | |
| 148 | + $iconBg = $styles[$state]['iconBg']; | |
| 122 | 149 | ?> |
| 123 | 150 | <div class="fct-thank-you-page-header" style="background: <?php echo esc_attr($bgColor); ?>;"> |
| 124 | - <?php if ($order->payment_status !== 'paid') : ?> | |
| 125 | - <div class="fct-thank-you-page-header-icon" style="background: <?php echo esc_attr($iconBg); ?>;"> | |
| 151 | + <div class="fct-thank-you-page-header-icon" style="background: <?php echo esc_attr($iconBg); ?>;"> | |
| 152 | + <?php if ($state === 'success') : ?> | |
| 153 | + <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" | |
| 154 | + stroke-width="3" stroke-linecap="round" stroke-linejoin="round"> | |
| 155 | + <polyline points="20,6 9,17 4,12"></polyline> | |
| 156 | + </svg> | |
| 157 | + <?php elseif ($state === 'failed') : ?> | |
| 158 | + <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" | |
| 159 | + stroke-width="3" stroke-linecap="round" stroke-linejoin="round"> | |
| 160 | + <line x1="18" y1="6" x2="6" y2="18"></line> | |
| 161 | + <line x1="6" y1="6" x2="18" y2="18"></line> | |
| 162 | + </svg> | |
| 163 | + <?php elseif ($state === 'refunded') : ?> | |
| 164 | + <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" | |
| 165 | + stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"> | |
| 166 | + <polyline points="9,14 4,9 9,4"></polyline> | |
| 167 | + <path d="M4 9h10a6 6 0 0 1 0 12h-3"></path> | |
| 168 | + </svg> | |
| 169 | + <?php else : ?> | |
| 126 | 170 | <svg class="w-64 h-64" xmlns="http://www.w3.org/2000/svg" |
| 127 | 171 | viewBox="0 0 1024 1024" fill="currentColor"> |
| 128 | 172 | <path |
| 129 | 173 | d="M480 674V192c0-18 14-32 32-32s32 14 32 32v482h-64zm0 63h64v60h-64v-60zM0 512C0 229 229 0 512 0s512 229 512 512-229 512-512 512S0 795 0 512zm961 0c0-247-202-448-449-448S64 265 64 512s201 448 448 448 449-201 449-448z"></path> |
| 130 | 174 | </svg> |
| 131 | - </div> | |
| 132 | - <h1 class="fct-thank-you-page-header-title" style="color:<?php echo esc_attr($titleColor); ?>"> | |
| 133 | - <?php echo esc_html__('Payment Pending!', 'fluent-cart'); ?> | |
| 134 | - </h1> | |
| 175 | + <?php endif; ?> | |
| 176 | + </div> | |
| 177 | + <h1 class="fct-thank-you-page-header-title" style="color:<?php echo esc_attr($titleColor); ?>;"> | |
| 178 | + <?php echo esc_html($titles[$state]); ?> | |
| 179 | + </h1> | |
| 135 | 180 | |
| 136 | - <?php else: ?> | |
| 137 | - <div class="fct-thank-you-page-header-icon" style="background: <?php echo esc_attr($iconBg); ?>;"> | |
| 138 | - <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" | |
| 139 | - stroke-width="3" stroke-linecap="round" stroke-linejoin="round"> | |
| 140 | - <polyline points="20,6 9,17 4,12"></polyline> | |
| 141 | - </svg> | |
| 142 | - </div> | |
| 143 | - <h1 class="fct-thank-you-page-header-title" style="color:<?php echo esc_attr($titleColor); ?>;"> | |
| 144 | - <?php echo esc_html__('Purchase Successful!', 'fluent-cart'); ?> | |
| 145 | - </h1> | |
| 146 | - <?php endif; ?> | |
| 147 | - | |
| 148 | 181 | <?php do_action('fluent_cart/receipt/thank_you/after_header_title', $this->config); ?> |
| 149 | 182 | |
| 150 | 183 | </div> |
| 151 | 184 | |
| @@ -206,9 +239,10 @@ | ||
| 206 | 239 | esc_html($order->customer->full_name) |
| 207 | 240 | ); |
| 208 | 241 | ?> |
| 209 | 242 | </div> |
| 210 | - <?php if ($order->payment_status === 'paid') : ?> | |
| 243 | + <?php $state = $this->getHeaderState(); ?> | |
| 244 | + <?php if ($state === 'success') : ?> | |
| 211 | 245 | <p> |
| 212 | 246 | <?php |
| 213 | 247 | printf( |
| 214 | 248 | '%s<strong style="color: #007bff;"><a href="%s">#%s</a></strong>%s', |
| @@ -218,8 +252,34 @@ | ||
| 218 | 252 | esc_html__(' has been placed successfully.', 'fluent-cart') |
| 219 | 253 | ); |
| 220 | 254 | ?> |
| 221 | 255 | </p> |
| 256 | + <?php elseif ($state === 'refunded') : ?> | |
| 257 | + <p> | |
| 258 | + <?php | |
| 259 | + printf( | |
| 260 | + '%s<strong style="color: #007bff;"><a href="%s">#%s</a></strong>%s', | |
| 261 | + esc_html__('Your order ', 'fluent-cart'), | |
| 262 | + esc_url($profilePage . 'order/' . $order->uuid), | |
| 263 | + esc_html($order->invoice_no), | |
| 264 | + esc_html__(' has been refunded.', 'fluent-cart') | |
| 265 | + ); | |
| 266 | + ?> | |
| 267 | + </p> | |
| 268 | + <?php elseif ($state === 'failed') : ?> | |
| 269 | + <p> | |
| 270 | + <?php | |
| 271 | + printf( | |
| 272 | + '%s<strong style="color: #007bff;"><a href="%s">#%s</a></strong>%s <a style="color: #007bff;" target="_blank" href="%s">%s</a>.', | |
| 273 | + esc_html__('The payment for your order ', 'fluent-cart'), | |
| 274 | + esc_url($profilePage . 'order/' . $order->uuid), | |
| 275 | + esc_html($order->invoice_no), | |
| 276 | + esc_html__(' could not be completed. You can try again from', 'fluent-cart'), | |
| 277 | + esc_url(\FluentCart\App\Services\Payments\PaymentHelper::getCustomPaymentLink($order->uuid)), | |
| 278 | + esc_html__('here', 'fluent-cart') | |
| 279 | + ); | |
| 280 | + ?> | |
| 281 | + </p> | |
| 222 | 282 | <?php else: ?> |
| 223 | 283 | <p> |
| 224 | 284 | |
| 225 | 285 | <?php |
| @@ -621,9 +681,9 @@ | ||
| 621 | 681 | echo sprintf( |
| 622 | 682 | /* translators: 1: Next billing date */ |
| 623 | 683 | esc_html__('- Auto renews on %1$s', 'fluent-cart'), |
| 624 | 684 | esc_html( |
| 625 | - \FluentCart\App\Services\DateTime\DateTime::gmtToTimezone($subs->next_billing_date)->format('M d, Y h:i A') | |
| 685 | + \FluentCart\App\Services\DateTime\DateFormatter::format($subs->next_billing_date, true, $order) | |
| 626 | 686 | ) |
| 627 | 687 | ); |
| 628 | 688 | ?> |
| 629 | 689 | </p> |