@@ -104,19 +104,33 @@ public function wcdp_modify_template($template = '', $template_name = '', $args
104104 return $ template ;
105105 }
106106
107+ $ order = null ;
108+ if (isset ($ args ['order ' ])) {
109+ $ order = $ args ['order ' ];
110+ } else if (isset ($ args ['order_id ' ])) {
111+ $ order = wc_get_order ($ args ['order_id ' ]);
112+ }
107113 $ path = WCDP_DIR . 'includes/wc-templates/ ' ;
108114 $ donable = WCDP_Form::is_donable (get_queried_object_id ());
109115
110116 switch ($ template_name ) {
111117 case 'checkout/review-order.php ' :
112118 case 'checkout/form-login.php ' :
113- case 'checkout/thankyou.php ' :
114119 case 'checkout/cart-errors.php ' :
115120 case 'checkout/form-checkout.php ' :
116- case 'checkout/order-receipt.php ' :
117121 case 'checkout/payment.php ' :
118122 case 'checkout/form-billing.php ' :
123+ if (
124+ get_option ('wcdp_compatibility_mode ' , 'no ' ) === 'no ' &&
125+ WCDP_Form::cart_contains_only_donations ()
126+ ) {
127+ $ template = $ path . $ template_name ;
128+ }
129+ break ;
130+
131+ case 'checkout/order-receipt.php ' :
119132 case 'checkout/order-received.php ' :
133+ case 'checkout/thankyou.php ' :
120134
121135 case 'myaccount/dashboard.php ' :
122136 case 'myaccount/view-order.php ' :
@@ -152,6 +166,13 @@ public function wcdp_modify_template($template = '', $template_name = '', $args
152166 case 'emails/plain/admin-new-order.php ' :
153167 case 'emails/plain/admin-failed-order.php ' :
154168 case 'emails/plain/admin-cancelled-order.php ' :
169+ if (
170+ get_option ('wcdp_compatibility_mode ' , 'no ' ) === 'no ' &&
171+ ($ order === null || WCDP_Form::order_contains_only_donations ($ order ))
172+ ) {
173+ $ template = $ path . $ template_name ;
174+ }
175+ break ;
155176
156177 case 'loop/no-products-found.php ' :
157178 if (get_option ('wcdp_compatibility_mode ' , 'no ' ) === 'no ' ) {
@@ -279,9 +300,12 @@ public function wcdp_order_button_html($html)
279300 *
280301 * @return string
281302 */
282- public function wcdp_order_button_text (): string
303+ public function wcdp_order_button_text ($ label ): string
283304 {
284- return __ ('Donate now ' , 'wc-donation-platform ' );
305+ if (WCDP_Form::cart_contains_only_donations (WC ()->cart )) {
306+ return __ ('Donate now ' , 'wc-donation-platform ' );
307+ }
308+ return $ label ;
285309 }
286310
287311 /**
0 commit comments