AbandonedCheckoutListTable.php
2 years ago
AbandonedCheckoutScriptsController.php
3 years ago
AbandonedCheckoutStatsScriptsController.php
3 years ago
AbandonedCheckoutViewController.php
2 years ago
AbandonedCheckoutViewController.php
61 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCart\Controllers\Admin\Abandoned; |
| 4 | |
| 5 | use SureCart\Controllers\Admin\Abandoned\AbandonedCheckoutListTable; |
| 6 | use SureCart\Controllers\Admin\AdminController; |
| 7 | |
| 8 | /** |
| 9 | * Handles product admin requests. |
| 10 | */ |
| 11 | class AbandonedCheckoutViewController extends AdminController { |
| 12 | /** |
| 13 | * Index. |
| 14 | */ |
| 15 | public function index() { |
| 16 | $this->withHeader( |
| 17 | array( |
| 18 | 'breadcrumbs' => [ |
| 19 | 'orders' => [ |
| 20 | 'title' => __( 'Abandoned Checkouts', 'surecart' ), |
| 21 | ], |
| 22 | ], |
| 23 | 'test_mode_toggle' => true, |
| 24 | ) |
| 25 | ); |
| 26 | |
| 27 | // enqueue stats. |
| 28 | add_action( 'admin_enqueue_scripts', \SureCart::closure()->method( AbandonedCheckoutStatsScriptsController::class, 'enqueue' ) ); |
| 29 | |
| 30 | $table = new AbandonedCheckoutListTable(); |
| 31 | $table->prepare_items(); |
| 32 | return \SureCart::view( 'admin/abandoned-orders/index' )->with( |
| 33 | [ |
| 34 | 'table' => $table, |
| 35 | 'enabled' => \SureCart::account()->entitlements->abandoned_checkouts ?? false, |
| 36 | ] |
| 37 | ); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Edit abandoned order. |
| 42 | */ |
| 43 | public function edit( $request ) { |
| 44 | // enqueue needed script. |
| 45 | add_action( 'admin_enqueue_scripts', \SureCart::closure()->method( AbandonedCheckoutScriptsController::class, 'enqueue' ) ); |
| 46 | |
| 47 | $this->preloadPaths( |
| 48 | [ |
| 49 | '/wp/v2/settings', |
| 50 | '/wp/v2/users/me', |
| 51 | '/wp/v2/types?context=view', |
| 52 | '/wp/v2/types?context=edit', |
| 53 | '/surecart/v1/abandoned_checkouts/' . $request->query( 'id' ) . '?context=edit&expand%5B0%5D=promotion&expand%5B1%5D=promotion.coupon&expand%5B2%5D=recovered_checkout&expand%5B3%5D=checkout&expand%5B4%5D=customer&expand%5B5%5D=checkout.tax_identifier&expand%5B6%5D=checkout.shipping_address&expand%5B7%5D=checkout.discount&expand%5B8%5D=checkout.line_items&expand%5B9%5D=discount.promotion&expand%5B10%5D=line_item.price&expand%5B11%5D=line_item.fees&expand%5B12%5D=customer.balances&expand%5B13%5D=price.product', |
| 54 | ] |
| 55 | ); |
| 56 | |
| 57 | // return view. |
| 58 | return '<div id="app"></div>'; |
| 59 | } |
| 60 | } |
| 61 |