Skip to content

Commit 0e52c14

Browse files
WooCommerce Plugin Updates
1 parent 9698c55 commit 0e52c14

File tree

2,027 files changed

+252631
-1431
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,027 files changed

+252631
-1431
lines changed

.github/workflows/build.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Build
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- reopened
8+
push:
9+
branches-ignore:
10+
- 'master'
11+
12+
jobs:
13+
phpcs:
14+
runs-on: ubuntu-latest
15+
16+
strategy:
17+
matrix:
18+
php-version: [ 8.0, 8.1, 8.2 ]
19+
20+
steps:
21+
- uses: actions/checkout@v3
22+
- uses: php-actions/composer@v6
23+
with:
24+
php_version: ${{ matrix.php-version }}
25+
args: --ignore-platform-req=php
26+
- name: Run WordPress code standard
27+
run: |
28+
./vendor/bin/phpcs --ignore=vendor,wpcs --standard=./phpcs.xml ./

.travis.yml

-11
This file was deleted.

BitPayLib/BPC_Buttons.php

-24
This file was deleted.

BitPayLib/BPC_Client.php

-11
This file was deleted.

BitPayLib/BPC_Configuration.php

-56
This file was deleted.

BitPayLib/BPC_Invoice.php

-107
This file was deleted.

BitPayLib/BPC_Item.php

-21
This file was deleted.

BitPayLib/BPC_Token.php

-26
This file was deleted.

BitPayLib/class-bitpaycancelorder.php

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace BitPayLib;
6+
7+
/**
8+
* Plugin Name: BitPay Checkout for WooCommerce
9+
* Plugin URI: https://www.bitpay.com
10+
* Description: BitPay Checkout Plugin
11+
* Version: 5.0.0
12+
* Author: BitPay
13+
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
14+
*/
15+
class BitPayCancelOrder {
16+
17+
private BitPayCart $bitpay_cart;
18+
private BitPayCheckoutTransactions $transactions;
19+
private BitPayLogger $logger;
20+
21+
public function __construct( BitPayCart $cart, BitPayCheckoutTransactions $transactions, BitPayLogger $logger ) {
22+
$this->bitpay_cart = $cart;
23+
$this->transactions = $transactions;
24+
$this->logger = $logger;
25+
}
26+
27+
public function execute( \WP_REST_Request $request ): void {
28+
$invoice_id = $request->get_param( 'invoiceid' );
29+
if ( ! $invoice_id ) {
30+
die();
31+
}
32+
33+
$this->bitpay_cart->load_cart();
34+
$order_id = $this->transactions->get_order_id_by_invoice_id( $invoice_id );
35+
if ( ! $order_id ) {
36+
die();
37+
}
38+
$order = new \WC_Order( $order_id );
39+
$items = $order->get_items();
40+
41+
$this->logger->execute( 'User canceled order: ' . $order_id . ', removing from WooCommerce', 'USER CANCELED ORDER', true );
42+
$order->add_order_note( 'User closed the modal, the order will be set to canceled state' );
43+
$order->update_status( 'cancelled', __( 'BitPay payment canceled by user', 'woocommerce' ) );
44+
45+
// clear the cart first so things dont double up.
46+
WC()->cart->empty_cart();
47+
foreach ( $items as $item ) {
48+
// now insert for each quantity.
49+
$item_count = $item->get_quantity();
50+
for ( $i = 0; $i < $item_count; $i++ ) :
51+
WC()->cart->add_to_cart( $item->get_product_id() );
52+
endfor;
53+
}
54+
55+
$this->clear_cookie_for_invoice_id();
56+
}
57+
58+
private function clear_cookie_for_invoice_id(): void {
59+
setcookie( 'bitpay-invoice-id', '', time() - 3600 );
60+
}
61+
}

BitPayLib/class-bitpaycart.php

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace BitPayLib;
6+
7+
/**
8+
* Plugin Name: BitPay Checkout for WooCommerce
9+
* Plugin URI: https://www.bitpay.com
10+
* Description: BitPay Checkout Plugin
11+
* Version: 5.0.0
12+
* Author: BitPay
13+
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
14+
*/
15+
class BitPayCart {
16+
17+
public function execute(): void {
18+
add_action( 'init', 'woocommerce_clear_cart_url' );
19+
}
20+
21+
public function woocommerce_clear_cart_url(): void {
22+
if ( isset( $_GET['custompage'] ) ) { // phpcs:ignore
23+
global $woocommerce;
24+
$woocommerce->cart->empty_cart();
25+
}
26+
}
27+
28+
public function load_cart(): void {
29+
if ( is_null( WC()->cart ) ) {
30+
wc_load_cart();
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)