Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
]
},
"type": "magento2-metapackage",
"version": "1.0.0",
"version": "1.0.0.4",
"authors": [
{
"name": "Andresa Martins",
Expand All @@ -48,4 +48,4 @@
"url": "https://repo.magento.com/"
}
]
}
}
10 changes: 8 additions & 2 deletions popup-admin/Model/Config/Source/Carousel.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ public function toOptionArray()
return [
['value' => '_bestSellerProducts', 'label' => __('Best Sellers')],
['value' => '_latestProducts', 'label' => __('Latest Products')],
['value' => '_randomProducts', 'label' => __('Random Products')]
['value' => '_randomProducts', 'label' => __('Random Products')],
['value' => '_upSellingProducts', 'label' => __('Up-Sell Products')],
['value' => '_relatedProducts', 'label' => __('Related Products')],
['value' => '_crossSellProducts', 'label' => __('Cross-Sell Products')]
];
}

Expand All @@ -37,7 +40,10 @@ public function toArray()
return [
'_bestSellerProducts' => __('Best Sellers'),
'_latestProducts' => __('Latest Products'),
'_randomProducts' => __('Random Products')
'_randomProducts' => __('Random Products'),
'_upSellingProducts' => __('Up-Sell Products'),
'_relatedProducts' => __('Related Products'),
'_crossSellProducts' => __('Cross-Sell Products')
];
}
}
1 change: 1 addition & 0 deletions popup-admin/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
showInWebsite="1" showInStore="1" canRestore="1">
<label>Product Display</label>
<source_model>Prestafy\PopupAdmin\Model\Config\Source\Carousel</source_model>
<comment>If no products are found in the selection, random products are always displayed.</comment>
</field>
</group>
</section>
Expand Down
80 changes: 78 additions & 2 deletions popup-display/CustomerData/PopupCartData.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
use Magento\Framework\Pricing\Helper\Data as PricingHelper;
use Magento\Sales\Model\ResourceModel\Report\Bestsellers\CollectionFactory as BestSellersCollectionFactory;
use Prestafy\PopupDisplay\Helper\Data as Helper;
use Magento\Checkout\Model\Session as CheckoutSession;
use Magento\Catalog\Api\ProductRepositoryInterface as ProductRepositoryInterface;

/**
* PopupCart source
Expand Down Expand Up @@ -73,6 +75,13 @@ class PopupCartData implements SectionSourceInterface
*/
protected $bestSellersCollectionFactory;

/**
* @var \Magento\Checkout\Model\Session
*/
protected $checkoutSession;

protected $productRepository;

/**
* @param CollectionFactory $collectionFactory
* @param Image $catalogImage
Expand All @@ -81,6 +90,9 @@ class PopupCartData implements SectionSourceInterface
* @param Visibility $productVisibility
* @param CartHelper $cartHelper
* @param Helper $helper
* @param BestSellersCollectionFactory $bestSellersCollectionFactory
* @param CheckoutSession $checkoutSession
* @param ProductRepositoryInterface $productRepository
* @codeCoverageIgnore
*/
public function __construct(
Expand All @@ -91,7 +103,9 @@ public function __construct(
Visibility $productVisibility,
CartHelper $cartHelper,
Helper $helper,
BestSellersCollectionFactory $bestSellersCollectionFactory
BestSellersCollectionFactory $bestSellersCollectionFactory,
CheckoutSession $checkoutSession,
ProductRepositoryInterface $productRepository
)
{
$this->collectionFactory = $collectionFactory;
Expand All @@ -102,6 +116,8 @@ public function __construct(
$this->cartHelper = $cartHelper;
$this->helper = $helper;
$this->bestSellersCollectionFactory = $bestSellersCollectionFactory;
$this->checkoutSession = $checkoutSession;
$this->productRepository = $productRepository;

$this->_initCollection();
}
Expand All @@ -120,7 +136,6 @@ public function getSectionData()
'cartTotalCount' => $this->cartHelper->getSummaryCount(),
'products' => $this->_getCollection()
];

return $output;
}

Expand Down Expand Up @@ -221,4 +236,65 @@ private function _bestSellerProducts()
$this->collection->addIdFilter($productIds);
}
}

/**
* Create collection with UpSelling products
*/
private function _upSellingProducts()
{
$productIds = [];
if (!empty($this->checkoutSession->getLastAddedProductId())) {
$product = $this->productRepository->getById($this->checkoutSession->getLastAddedProductId());
$upSellProducts = $product->getUpSellProducts();

foreach ($upSellProducts as $upSellProduct) {
$productIds[] = $upSellProduct->getId();
}
}

if (empty($productIds)) {
$this->_randomProducts();
} else {
$this->collection->addIdFilter($productIds);
}
}

private function _relatedProducts()
{
$productIds = [];
if (!empty($this->checkoutSession->getLastAddedProductId())) {
$product = $this->productRepository->getById($this->checkoutSession->getLastAddedProductId());
$relatedProducts = $product->getRelatedProducts();

foreach ($relatedProducts as $relatedProduct) {
$productIds[] = $relatedProduct->getId();
}
}

if (empty($productIds)) {
$this->_randomProducts();
} else {
$this->collection->addIdFilter($productIds);
}
}

private function _crossSellProducts()
{
$productIds = [];
if (!empty($this->checkoutSession->getLastAddedProductId())) {
$product = $this->productRepository->getById($this->checkoutSession->getLastAddedProductId());
$crossSellProducts = $product->getCrossSellProducts();

foreach ($crossSellProducts as $crossSellProduct) {
$productIds[] = $crossSellProduct->getId();
}
}

if (empty($productIds)) {
$this->_randomProducts();
} else {
$this->collection->addIdFilter($productIds);
}
}

}
7 changes: 7 additions & 0 deletions popup-display/i18n/de_AT.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"A new item has been added to your Shopping Cart. ","Der Artikel wurde Ihrem Warenkorb hinzugefügt. "
"You now have %s items in your Shopping Cart.","Sie haben %s Artikel in Ihrem Warenkorb."
"View Shopping Cart","Warenkorb ansehen"
"Continue Shopping","Mit dem Einkaufen fortfahren"
"Other Items You Might Be Interested In:","Kunden, die diesen Artikel gekauft haben, kauften auch:"
Close,Schließen
"Incl. Tax, plus shipping","Inkl. MwSt., zzgl. Versand"
7 changes: 7 additions & 0 deletions popup-display/i18n/de_CH.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"A new item has been added to your Shopping Cart. ","Der Artikel wurde Ihrem Warenkorb hinzugefügt. "
"You now have %s items in your Shopping Cart.","Sie haben %s Artikel in Ihrem Warenkorb."
"View Shopping Cart","Warenkorb ansehen"
"Continue Shopping","Mit dem Einkaufen fortfahren"
"Other Items You Might Be Interested In:","Kunden, die diesen Artikel gekauft haben, kauften auch:"
Close,Schließen
"Incl. Tax, plus shipping","Inkl. MwSt., zzgl. Versand"
7 changes: 7 additions & 0 deletions popup-display/i18n/de_DE.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"A new item has been added to your Shopping Cart. ","Der Artikel wurde Ihrem Warenkorb hinzugefügt. "
"You now have %s items in your Shopping Cart.","Sie haben %s Artikel in Ihrem Warenkorb."
"View Shopping Cart","Warenkorb ansehen"
"Continue Shopping","Mit dem Einkaufen fortfahren"
"Other Items You Might Be Interested In:","Kunden, die diesen Artikel gekauft haben, kauften auch:"
Close,Schließen
"Incl. Tax, plus shipping","Inkl. MwSt., zzgl. Versand"
7 changes: 7 additions & 0 deletions popup-display/i18n/de_IT.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"A new item has been added to your Shopping Cart. ","Der Artikel wurde Ihrem Warenkorb hinzugefügt. "
"You now have %s items in your Shopping Cart.","Sie haben %s Artikel in Ihrem Warenkorb."
"View Shopping Cart","Warenkorb ansehen"
"Continue Shopping","Mit dem Einkaufen fortfahren"
"Other Items You Might Be Interested In:","Das könnte Sie auch interessieren:"
Close,Schließen
"Incl. Tax, plus shipping","Inkl. MwSt., zzgl. Versand"
1 change: 1 addition & 0 deletions popup-display/view/frontend/web/css/cartpopup.css
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
@media only screen and (max-width: 767px) {
.no-header-footer .modal-product-list li {
width: 50%;
height: 280px;
}

.no-header-footer .continue-shopping {
Expand Down
34 changes: 34 additions & 0 deletions popup-display/view/frontend/web/css/source/_module.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Cart popup component styles
//
// @category Prestafy
// @package Prestafy_PopupDisplay
// @author Andresa Martins <contact@andresa.dev>
// @copyright Copyright (c) 2019 Prestafy eCommerce Solutions (https://www.prestafy.com.br)
// @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
//

// This is for styles that are used in both mobile and desktop views
// Common
//--------------------------------------
//& when (@media-common = true) {
//
//}


// This is for styles that will only be included in the styles-l.css file.
// Desktop
// _____________________________________________

//.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) {
//
//}


// And this is for all mobile styles
// Mobile
// _____________________________________________

//.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__m) {
//
//}

36 changes: 26 additions & 10 deletions popup-display/view/frontend/web/template/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,37 @@
<button type="button" class="view-shopping-cart" data-bind="event: {click: viewShoppingCart}">
<!-- ko i18n: 'View Shopping Cart' --><!-- /ko --></button>
<button type="button" class="continue-shopping" data-bind="event: { click: closeModal }">
<!-- ko i18n: 'Continue Shopping' --><!-- /ko --></button>
<!-- ko i18n: 'Continue shopping' --><!-- /ko --></button>
</p>
</div>
</div>
<div class="modal-popup-body">
<div class="modal-popup-body block widget">
<p><!-- ko i18n: 'Other Items You Might Be Interested In:' --><!-- /ko --></p>
<div data-bind="foreach: products">
<ul data-bind="foreach:Object.keys($data)" class="modal-product-list">
<li>
<a data-bind="attr: { href: $parent[$data].product_url }">
<img data-bind="attr: { src: $parent[$data].product_image }" width="155" height="155"/>
</a>
<span><strong data-bind="text: $parent[$data].product_price"></strong></span>
<div data-bind="foreach: products" class="products-grid grid">
<ol data-bind="foreach: Object.keys($data)" class="modal-product-list product-items widget-product-grid">
<li class="product-item">
<div class="product-item-info">
<a class="product-item-photo" data-bind="attr: { href: $parent[$data].product_url, title: $parent[$data].name }">
<img data-bind="attr: { src: $parent[$data].product_image }" max-width="240" max-height="300"/>
</a>
<div class="product-item-details">
<strong class="product-item-name">
<a data-bind="attr: { href: $parent[$data].product_url, title: $parent[$data].name }" class="product-item-link">
<span data-bind="html: $parent[$data].name"></span>
</a>
</strong>
<div class="price-box price-final_price">
<div data-bind="html: $parent[$data].product_price" class="price"></div>
</div>
<div class="product-tax-details">
<!-- ko i18n: 'Incl. Tax, plus shipping' --><!-- /ko -->
</div>
<div class="product-item-actions">
</div>
</div>
</div>
</li>
</ul>
</ol>
</div>
</div>