Skip to content

Commit

Permalink
#164 when products has deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
xxl4 committed Apr 12, 2024
1 parent c6f4402 commit 75c220a
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 2 deletions.
63 changes: 63 additions & 0 deletions packages/Nicelizhi/OneBuy/src/Console/Commands/Paypal/OrderGet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
namespace Nicelizhi\OneBuy\Console\Commands\Paypal;

use Exception;
use Illuminate\Console\Command;
use GuzzleHttp\Client;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redis;
use Maatwebsite\Excel\Facades\Excel;
use Webkul\Sales\Repositories\OrderRepository;
use Webkul\Checkout\Repositories\CartRepository;
use Webkul\Checkout\Facades\Cart;
use Webkul\Paypal\Payment\SmartButton;

class OrderGet extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'onebuy:paypal:order:get';

/**
* The console command description.
*
* @var string
*/
protected $description = 'paypal order';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct(
protected SmartButton $smartButton,
protected OrderRepository $orderRepository,
protected CartRepository $cartRepository
)
{
parent::__construct();
}

private $cache_key = "faq";

private $cart;

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$orderID = "5JK60257HG619343A";

$order = $this->smartButton->getOrder($orderID);

var_dump($order);

}
}
5 changes: 5 additions & 0 deletions packages/Webkul/FPC/src/Listeners/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Webkul\Product\Repositories\ProductRepository;
use Webkul\Product\Repositories\ProductBundleOptionProductRepository;
use Webkul\Product\Repositories\ProductGroupedProductRepository;
use Illuminate\Support\Facades\Log;

class Product
{
Expand Down Expand Up @@ -63,8 +64,12 @@ public function getForgettableUrls($product)
{
$urls = [];

Log::info("product " . json_encode($product));

$products = $this->getAllRelatedProducts($product);



foreach ($products as $product) {
$urls[] = '/' . $product->url_key;
}
Expand Down
10 changes: 8 additions & 2 deletions packages/Webkul/FPC/src/Listeners/Refund.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Webkul\FPC\Listeners;

use Spatie\ResponseCache\Facades\ResponseCache;
use Illuminate\Support\Facades\Log;

class Refund extends Product
{
Expand All @@ -15,9 +16,14 @@ class Refund extends Product
public function afterCreate($refund)
{
foreach ($refund->items as $item) {
$urls = $this->getForgettableUrls($item->product);

ResponseCache::forget($urls);
Log::info("item product " . json_encode($item->product));
if(!is_null($item->product)) { // when the product has deleted, and need to check it todo
$urls = $this->getForgettableUrls($item->product);

ResponseCache::forget($urls);
}

}
}
}

0 comments on commit 75c220a

Please sign in to comment.