From 93c3fd30169f185a87833eb9ea3e572b3440b29d Mon Sep 17 00:00:00 2001 From: Antony Thorpe <1023740+AntonyThorpe@users.noreply.github.com> Date: Fri, 3 May 2024 08:33:43 +1200 Subject: [PATCH] Update PopulateCartTask.php (#824) Deprecated: replace Member::currentUser() with Security::getCurrentUser() Update various docs --- docs/en/02_Customisation/01_Recipes/Custom_Checkout.md | 2 +- docs/en/02_Customisation/01_Recipes/Multi_Step_Checkout.md | 2 +- src/Tasks/PopulateCartTask.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/en/02_Customisation/01_Recipes/Custom_Checkout.md b/docs/en/02_Customisation/01_Recipes/Custom_Checkout.md index fa8f8ef07..54e0798a5 100644 --- a/docs/en/02_Customisation/01_Recipes/Custom_Checkout.md +++ b/docs/en/02_Customisation/01_Recipes/Custom_Checkout.md @@ -29,7 +29,7 @@ class MyCustomCheckoutComponentConfig extends CheckoutComponentConfig { parent::__construct($order); $this->addComponent(CustomerDetailsCheckoutComponent::create()); - if (Checkout::member_creation_enabled() && !Member::currentUserID()) { + if (Checkout::member_creation_enabled() && !Security::getCurrentUser()) { $this->addComponent(MembershipCheckoutComponent::create()); } if (count(GatewayInfo::getSupportedGateways()) > 1) { diff --git a/docs/en/02_Customisation/01_Recipes/Multi_Step_Checkout.md b/docs/en/02_Customisation/01_Recipes/Multi_Step_Checkout.md index 7a3bbe06d..377387f0c 100644 --- a/docs/en/02_Customisation/01_Recipes/Multi_Step_Checkout.md +++ b/docs/en/02_Customisation/01_Recipes/Multi_Step_Checkout.md @@ -127,7 +127,7 @@ public function getData(Order $order) { return array( 'Organisation' => $order->Organisation, ... - if($member = Member::currentUser()){ + if($member = Security::getCurrentUser()){ return array( 'Organisation' => $member->Organisation, ... diff --git a/src/Tasks/PopulateCartTask.php b/src/Tasks/PopulateCartTask.php index 9e9426a59..30500e74e 100644 --- a/src/Tasks/PopulateCartTask.php +++ b/src/Tasks/PopulateCartTask.php @@ -7,7 +7,7 @@ use SilverShop\Page\Product; use SilverStripe\Control\Controller; use SilverStripe\Dev\BuildTask; -use SilverStripe\Security\Member; +use SilverStripe\Security\Security; use SilverStripe\Versioned\Versioned; /** @@ -30,7 +30,7 @@ public function run($request) $product = $variations->sort('RAND()')->first(); } $quantity = (int)rand(1, 5); - if ($product->canPurchase(Member::currentUser(), $quantity)) { + if ($product->canPurchase(Security::getCurrentUser(), $quantity)) { $cart->add($product, $quantity); } }