Skip to content

Commit

Permalink
Restore Retail mode - catalog web price (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
livca-smile authored Jul 16, 2024
1 parent 723b4aa commit 88b7d02
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 28 deletions.
9 changes: 5 additions & 4 deletions Plugin/ContextPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ public function aroundDispatch(
RequestInterface $request
): mixed {

// show product offer price if shop has been selected, even in Retail mode
if ($this->settingsHelper->isDriveMode() || $this->currentStore->getRetailer()) {
if ($this->settingsHelper->isDriveMode()) {
// Set a default value to have common vary for all customers without any chosen retailer.
$retailerId = 'default';

if ($this->currentStore->getRetailer()
&& $this->currentStore->getRetailer()->getId()) {
if (
$this->currentStore->getRetailer()
&& $this->currentStore->getRetailer()->getId()
) {
$retailerId = $this->currentStore->getRetailer()->getId();
}

Expand Down
28 changes: 4 additions & 24 deletions Plugin/ProductPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Closure;
use Magento\Catalog\Model\Product;
use Smile\Retailer\Api\Data\RetailerInterface;
use Smile\RetailerOffer\Helper\Offer;
use Smile\RetailerOffer\Helper\Settings;
use Smile\StoreLocator\CustomerData\CurrentStore;
Expand All @@ -16,28 +15,13 @@
*/
class ProductPlugin
{

public function __construct(
private Offer $offerHelper,
private Settings $settingsHelper,
protected CurrentStore $currentStore
) {
}

/**
* Retrieve current retailer.
*/
private function getRetailer(): ?RetailerInterface
{
$retailer = null;
if ($this->currentStore->getRetailer() && $this->currentStore->getRetailer()->getId()) {
/** @var RetailerInterface $retailer */
$retailer = $this->currentStore->getRetailer();
}

return $retailer;
}

/**
* Return offer availability (if any) instead of the product one.
*
Expand All @@ -47,8 +31,7 @@ public function aroundIsAvailable(Product $product, Closure $proceed): bool
{
$isAvailable = $proceed();

// show product availability if shop has been selected, even in Retail mode
if ($this->settingsHelper->useStoreOffers() || $this->getRetailer()) {
if ($this->settingsHelper->useStoreOffers()) {
$isAvailable = false;
$offer = $this->offerHelper->getCurrentOffer($product);

Expand All @@ -67,8 +50,7 @@ public function aroundGetPrice(Product $product, Closure $proceed): mixed
{
$price = $proceed();

// show product offer price if shop has been selected, even in Retail mode
if ($this->settingsHelper->useStoreOffers() || $this->getRetailer()) {
if ($this->settingsHelper->useStoreOffers()) {
$offer = $this->offerHelper->getCurrentOffer($product);

if ($offer && $offer->getPrice()) {
Expand All @@ -88,8 +70,7 @@ public function aroundGetSpecialPrice(Product $product, Closure $proceed): mixed
{
$price = $proceed();

// show product offer price if shop has been selected, even in Retail mode
if ($this->settingsHelper->useStoreOffers() || $this->getRetailer()) {
if ($this->settingsHelper->useStoreOffers()) {
$offer = $this->offerHelper->getCurrentOffer($product);

if ($offer && $offer->getSpecialPrice()) {
Expand All @@ -107,8 +88,7 @@ public function aroundGetFinalPrice(Product $product, Closure $proceed, mixed $q
{
$price = $proceed($qty);

// show product offer price if shop has been selected, even in Retail mode
if ($this->settingsHelper->useStoreOffers() || $this->getRetailer()) {
if ($this->settingsHelper->useStoreOffers()) {
$offer = $this->offerHelper->getCurrentOffer($product);

if ($offer) {
Expand Down

0 comments on commit 88b7d02

Please sign in to comment.