Skip to content

Commit d251618

Browse files
authored
Merge pull request #172
manual checkout dl link does not show in ty page
2 parents cd02fb3 + 3f2e7d4 commit d251618

4 files changed

Lines changed: 55 additions & 3 deletions

File tree

‎wp-express-checkout/admin/includes/class-orders-meta-boxes.php‎

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use WP_Express_Checkout\Products;
1111
use WP_Express_Checkout\Utils;
1212
use WP_Express_Checkout\Variations;
13+
use WP_Express_Checkout\Debug\Logger;
1314
use WP_Post;
1415

1516
/**
@@ -36,6 +37,7 @@ public function __construct() {
3637
add_action( 'wp_ajax_wpec_add_order_note', array( $this, 'wpec_add_order_note_callback' ) );
3738
add_action( 'wp_ajax_wpec_delete_order_note', array( $this, 'wpec_delete_order_note_callback' ) );
3839
add_action( 'wp_ajax_wpec_get_order_product_by_id', array( $this, 'wpec_get_order_product_by_id_callback' ) );
40+
add_action( 'wp_ajax_wpec_order_action_set_paid_and_send_email', array( $this, 'set_paid_and_send_email_callback' ) );
3941
}
4042

4143
public function add_meta_boxes() {
@@ -354,7 +356,7 @@ public function display_actions_meta_box( $post ){
354356

355357
try {
356358
$order = Orders::retrieve( $post->ID );
357-
$is_manual_payment = strpos($order->get_capture_id(), 'manual');
359+
$is_manual_payment = strtolower($order->get_payment_gateway()) == 'manual_checkout' || stripos($order->get_capture_id(), 'manual') !== false;
358360
$is_admin_checkout = strpos($order->get_capture_id(), 'admin');
359361
} catch ( Exception $exc ) {
360362
return;
@@ -377,7 +379,7 @@ public function display_actions_meta_box( $post ){
377379
</span>
378380
</a>
379381
</li>
380-
<?php if ($is_manual_payment === false && $is_admin_checkout === false) { // Don't show refund action button for manual payment or admin checkout?>
382+
<?php if ( empty($is_manual_payment) && $is_admin_checkout === false) { // Don't show refund action button for manual payment or admin checkout?>
381383
<li>
382384
<?php if( $order->get_status()=="refunded" ){ ?>
383385
<div class="wpec-grey-box">
@@ -395,6 +397,17 @@ public function display_actions_meta_box( $post ){
395397
<?php } ?>
396398
</li>
397399
<?php } ?>
400+
401+
<?php if ( !empty($is_manual_payment) && strtolower($order->get_status()) == 'pending' ) { ?>
402+
<li>
403+
<a class="button wpec-order-action" data-action="set_paid_and_send_email" data-order="<?php echo $order->get_id() ?>" data-nonce="<?php echo wp_create_nonce( 'set_paid_and_send_email' ); ?>" href="#">
404+
<span class="dashicons dashicons-yes-alt" style="line-height:1.8;font-size:16px;"></span>
405+
<span class="wpec-order-action-label">
406+
<?php esc_html_e( 'Set Order Paid & Send Email', 'wp-express-checkout' ); ?>
407+
</span>
408+
</a>
409+
</li>
410+
<?php } ?>
398411
</ul>
399412
<?php
400413

@@ -651,6 +664,29 @@ public function payment_refund_callback()
651664
wp_send_json_success( __( 'Order refunded successfully!', 'wp-express-checkout' ) );
652665
}
653666

667+
public function set_paid_and_send_email_callback(){
668+
669+
check_ajax_referer( 'set_paid_and_send_email', 'nonce' );
670+
671+
try {
672+
$order = Orders::retrieve( $_POST['order'] );
673+
674+
} catch ( Exception $exc ) {
675+
wp_send_json_error( $exc->getMessage() );
676+
}
677+
678+
Logger::log( "Setting order status to 'paid'." );
679+
$order->set_status('paid');
680+
681+
$response = Emails::send_buyer_email( $order );
682+
683+
if ( ! $response ) {
684+
wp_send_json_error( __( 'Something went wrong, email is not sent!', 'wp-express-checkout' ) );
685+
}
686+
687+
wp_send_json_success( __( 'Order has set to paid and buyer notification email sent successfully!', 'wp-express-checkout' ) );
688+
}
689+
654690
public function wpec_add_order_note_callback()
655691
{
656692
check_ajax_referer( 'wpec_add_order_note_ajax_nonce', 'nonce' );

‎wp-express-checkout/assets/js/admin.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@
136136
if( button_action == 'payment_refund'){
137137
console.log('Refund successful. Reloading the page.');
138138
window.location.reload();
139+
} else if (button_action == 'set_paid_and_send_email'){
140+
console.log('Order has set to paid and sale notification email sent. Reloading the page.');
141+
window.location.reload();
139142
}
140143
} )
141144
.fail( function() {

‎wp-express-checkout/public/views/templates/content-thank-you.php‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
$shipping_amount = ! empty( $order->get_item( 'shipping' ) ) ? $order->get_item( 'shipping' )['price'] : 0;
2121
$downloads = View_Downloads::get_order_downloads_list( $order->get_id() );
2222

23+
$order_status = $order->get_status();
24+
$payment_gateway = $order->get_payment_gateway();
25+
2326
$trial_payment_discount = $order->get_item( 'trial_discount' );
2427
$trial_payment = $order->get_item( 'trial' );
2528
?>
@@ -125,7 +128,14 @@
125128
</tbody>
126129
</table>
127130

128-
<?php if ( is_array( $downloads ) && ! empty( $downloads ) ) { ?>
131+
<?php
132+
$is_manual_checkout = strtolower($payment_gateway) == 'manual_checkout' || stripos($order->get_capture_id(), 'manual') !== false;
133+
$is_pending_manual_checkout = $is_manual_checkout && strtolower($order_status) == 'pending'; // Don't show digital download if its a manual checkout pending order.
134+
135+
$show_downloads = apply_filters('wpec_show_downloads_on_thank_you_page', !$is_pending_manual_checkout, $order);
136+
137+
if ( !empty($show_downloads) && is_array( $downloads ) && ! empty( $downloads ) ) {
138+
?>
129139
<h4><?php _e( "Downloads", "wp-express-checkout" ); ?></h4>
130140
<table class="wpec-order-downloads-table">
131141
<thead>

‎wp-express-checkout/readme.txt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ https://wp-express-checkout.com/
175175
None
176176

177177
== Changelog ==
178+
= WIP =
179+
* Digital download links now doesn't show in the thank you page for manual checkout pending order.
180+
* A new order action button added to set order status to paid and send sale notification email for manual checkout.
178181

179182
= 2.4.6 =
180183
* Use of template shortcode param removed for 'wpec_show_all_products' and 'wpec_show_products_from_category' shortcode.

0 commit comments

Comments
 (0)