Use different order statuses for virtual goods

This commit is contained in:
cryptochangements34 2017-12-28 09:22:55 -06:00 committed by GitHub
parent fbd51c0593
commit 1ca11855fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -214,6 +214,21 @@ class Monero_Gateway extends WC_Payment_Gateway
return false; return false;
} }
public function is_virtual_in_cart($order_id)
{
$order = wc_get_order( $order_id );
$items = $order->get_items();
foreach ( $items as $item ) {
$product = new WC_Product( $item['product_id'] );
if ( $product->is_virtual() ) {
return true;
}
}
return false;
}
public function instruction($order_id) public function instruction($order_id)
{ {
$order = wc_get_order($order_id); $order = wc_get_order($order_id);
@ -233,6 +248,9 @@ class Monero_Gateway extends WC_Payment_Gateway
// Seems that we can't connect with daemon, then set array_integrated_address, little hack // Seems that we can't connect with daemon, then set array_integrated_address, little hack
$array_integrated_address["integrated_address"] = $address; $array_integrated_address["integrated_address"] = $address;
} }
if($this->is_virtual_in_cart($order_id) == true){
echo "test";
}
$message = $this->verify_payment($payment_id, $amount_xmr2, $order); $message = $this->verify_payment($payment_id, $amount_xmr2, $order);
if ($this->confirmed) { if ($this->confirmed) {
$color = "006400"; $color = "006400";
@ -240,6 +258,7 @@ class Monero_Gateway extends WC_Payment_Gateway
$color = "DC143C"; $color = "DC143C";
} }
echo "<h4><font color=$color>" . $message . "</font></h4>"; echo "<h4><font color=$color>" . $message . "</font></h4>";
echo " echo "
<head> <head>
<!--Import Google Icon Font--> <!--Import Google Icon Font-->
@ -388,7 +407,13 @@ class Monero_Gateway extends WC_Payment_Gateway
$this->log->add('Monero_gateway', '[SUCCESS] Payment has been recorded. Congratulations!'); $this->log->add('Monero_gateway', '[SUCCESS] Payment has been recorded. Congratulations!');
$this->confirmed = true; $this->confirmed = true;
$order = wc_get_order($order_id); $order = wc_get_order($order_id);
if($this->is_virtual_in_cart($order_id) == true){
$order->update_status('completed', __('Payment has been received', 'monero_gateway')); $order->update_status('completed', __('Payment has been received', 'monero_gateway'));
}
else{
$order->update_status('processing', __('Payment has been received', 'monero_gateway'));
}
global $wpdb; global $wpdb;
$wpdb->query("DROP TABLE $payment_id"); // Drop the table from database after payment has been confirmed as it is no longer needed $wpdb->query("DROP TABLE $payment_id"); // Drop the table from database after payment has been confirmed as it is no longer needed