Commit b27e9b50 by liumengfei

修改样式

增加buy now功能
parent 15ce2546
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/pub/
RewriteCond %{REQUEST_URI} !^/setup/
RewriteCond %{REQUEST_URI} !^/update/
RewriteCond %{REQUEST_URI} !^/dev/
RewriteRule .* /pub/$0 [L]
DirectoryIndex index.php
<IfModule mod_deflate.c>
############################################
## enable apache served files compression
## http://developer.yahoo.com/performance/rules.html#gzip
# Insert filter on all content
###SetOutputFilter DEFLATE
# Insert filter on selected content types only
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript application/json image/svg+xml
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>
<?php
/**
* MagePrince
* Copyright (C) 2020 Mageprince <info@mageprince.com>
*
* @package Mageprince_BuyNow
* @copyright Copyright (c) 2020 Mageprince (http://www.mageprince.com/)
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License,version 3 (GPL-3.0)
* @author MagePrince <info@mageprince.com>
*/
namespace Mageprince\BuyNow\Block\Adminhtml\System\Config\Field;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
class Disable extends Field
{
/**
* @param AbstractElement $element
* @return string
*/
protected function _getElementHtml(AbstractElement $element)
{
$element->setDisabled('disabled');
return $element->getElementHtml();
}
}
<?php
/**
* MagePrince
* Copyright (C) 2020 Mageprince <info@mageprince.com>
*
* @package Mageprince_BuyNow
* @copyright Copyright (c) 2020 Mageprince (http://www.mageprince.com/)
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License,version 3 (GPL-3.0)
* @author MagePrince <info@mageprince.com>
*/
namespace Mageprince\BuyNow\Block\Product;
use Magento\Catalog\Block\Product\Context;
use Magento\Catalog\Block\Product\ProductList\Item\Block;
use Magento\Framework\App\ActionInterface;
use Magento\Framework\Url\Helper\Data as UrlHelper;
class ListProduct extends Block
{
/**
* @var UrlHelper
*/
protected $urlHelper;
/**
* ListProduct constructor.
* @param Context $context
* @param UrlHelper $urlHelper
* @param array $data
*/
public function __construct(
Context $context,
UrlHelper $urlHelper,
array $data = []
) {
$this->urlHelper = $urlHelper;
parent::__construct($context, $data);
}
/**
* Get post parameters
*
* @param \Magento\Catalog\Model\Product $product
* @return array
*/
public function getAddToCartPostParams(\Magento\Catalog\Model\Product $product)
{
$url = $this->getAddToCartUrl($product);
return [
'action' => $url,
'data' => [
'product' => $product->getEntityId(),
ActionInterface::PARAM_NAME_URL_ENCODED => $this->urlHelper->getEncodedUrl($url),
]
];
}
}
<?php
/**
* MagePrince
* Copyright (C) 2020 Mageprince <info@mageprince.com>
*
* @package Mageprince_BuyNow
* @copyright Copyright (c) 2020 Mageprince (http://www.mageprince.com/)
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License,version 3 (GPL-3.0)
* @author MagePrince <info@mageprince.com>
*/
namespace Mageprince\BuyNow\Controller\Cart;
use Magento\Framework\Filter\LocalizedToNormalized;
class Add extends \Magento\Checkout\Controller\Cart\Add
{
/**
* Add product to shopping cart action
*
* @return \Magento\Framework\Controller\Result\Redirect
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function execute()
{
if (!$this->_formKeyValidator->validate($this->getRequest())) {
$this->messageManager->addErrorMessage(
__('Your session has expired')
);
return $this->resultRedirectFactory->create()->setPath('*/*/');
}
$params = $this->getRequest()->getParams();
try {
if (isset($params['qty'])) {
$filter = new LocalizedToNormalized(
['locale' => $this->_objectManager->get(
\Magento\Framework\Locale\ResolverInterface::class
)->getLocale()]
);
$params['qty'] = $filter->filter($params['qty']);
}
$product = $this->_initProduct();
$related = $this->getRequest()->getParam('related_product');
/**
* Check product availability
*/
if (!$product) {
return $this->goBack();
}
$buyNowHelper = $this->_objectManager->create(\Mageprince\BuyNow\Helper\Data::class);
$cartProducts = $buyNowHelper->keepCartProducts();
if (!$cartProducts) {
$this->cart->truncate(); //remove all products from cart
}
$this->cart->addProduct($product, $params);
if (!empty($related)) {
$this->cart->addProductsByIds(explode(',', $related));
}
$this->cart->save();
/**
* @todo remove wishlist observer \Magento\Wishlist\Observer\AddToCart
*/
$this->_eventManager->dispatch(
'checkout_cart_add_product_complete',
['product' => $product, 'request' => $this->getRequest(), 'response' => $this->getResponse()]
);
if (!$this->_checkoutSession->getNoCartRedirect(true)) {
$baseUrl = $this->_url->getBaseUrl();
return $this->goBack($baseUrl . 'checkout/', $product);
}
} catch (\Magento\Framework\Exception\LocalizedException $e) {
if ($this->_checkoutSession->getUseNotice(true)) {
$this->messageManager->addNoticeMessage(
$this->_objectManager->get(\Magento\Framework\Escaper::class)->escapeHtml($e->getMessage())
);
} else {
$messages = array_unique(explode("\n", $e->getMessage()));
foreach ($messages as $message) {
$this->messageManager->addErrorMessage(
$this->_objectManager->get(\Magento\Framework\Escaper::class)->escapeHtml($message)
);
}
}
$url = $this->_checkoutSession->getRedirectUrl(true);
if (!$url) {
$cartUrl = $this->_objectManager->get(\Magento\Checkout\Helper\Cart::class)->getCartUrl();
$url = $this->_redirect->getRedirectUrl($cartUrl);
}
return $this->goBack($url);
} catch (\Exception $e) {
$this->messageManager->addException($e, __('We can\'t add this item to your shopping cart right now.'));
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
return $this->goBack();
}
}
}
<?php
/**
* MagePrince
* Copyright (C) 2020 Mageprince <info@mageprince.com>
*
* @package Mageprince_BuyNow
* @copyright Copyright (c) 2020 Mageprince (http://www.mageprince.com/)
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License,version 3 (GPL-3.0)
* @author MagePrince <info@mageprince.com>
*/
namespace Mageprince\BuyNow\Helper;
class Data extends \Magento\Framework\App\Helper\AbstractHelper
{
/**
* Buynow button title path
*/
const BUYNOW_BUTTON_TITLE_PATH = 'buynow/general/button_title';
/**
* Buynow button title
*/
const BUYNOW_BUTTON_TITLE = 'Buy Now';
/**
* Addtocart button form id path
*/
const ADDTOCART_FORM_ID_PATH = 'buynow/general/addtocart_id';
/**
* Addtocart button form id
*/
const ADDTOCART_FORM_ID = 'product_addtocart_form';
/**
* Keep cart products path
*/
const KEEP_CART_PRODUCTS_PATH = 'buynow/general/keep_cart_products';
/**
* Retrieve config value
*
* @return string
*/
public function getConfig($config)
{
return $this->scopeConfig->getValue(
$config,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
}
/**
* Get button title
* @return string
*/
public function getButtonTitle()
{
$btnTitle = $this->getConfig(self::BUYNOW_BUTTON_TITLE_PATH);
return $btnTitle ? $btnTitle : self::BUYNOW_BUTTON_TITLE;
}
/**
* Get addtocart form id
* @return string
*/
public function getAddToCartFormId()
{
$addToCartFormId = $this->getConfig(self::ADDTOCART_FORM_ID_PATH);
return $addToCartFormId ? $addToCartFormId : self::ADDTOCART_FORM_ID;
}
/**
* Check if keep cart products
* @return string
*/
public function keepCartProducts()
{
return $this->getConfig(self::KEEP_CART_PRODUCTS_PATH);
}
}
# Magento 2 BuyNow
This module add "BuyNow" button on product view page and list page to process directly checkout.
BuyNow Configuration: Stores->Configuration->MagePrince->Buy Now
# Notice
<b>We don't support Buy Now button on related, upsell, wishlist or any other places because it needs override core phtml files which is not the recommended solution. Please keep in note that most of the paid or free version of the Buy Now module overrides the core phtml files.</b>
# Copy below code to add Buy Now button in custom product sliders, widget, static blocks etc.
``````
$buyNowHtml = $this->getLayout()
->createBlock('Mageprince\BuyNow\Block\Product\ListProduct')
->setProduct($_item)
->setTemplate('Mageprince_BuyNow::buynow-list.phtml')
->toHtml();
echo $buyNowHtml;
``````
<b>Change `$_item` to current product object.</b>
You can use above code where you want to show buy now button in product. Please make sure don't copy this code to addtocart or any other form. Put this code after any `</form>`. Here is the screenshot of sample code of usage
<img src="https://user-images.githubusercontent.com/24751863/93671613-00aa9480-fac2-11ea-833b-5bd2c1d2a2fb.png" width="500"/>
# Installation Instruction
* Copy the content of the repo to the <b>app/code/Mageprince/BuyNow</b> folder
* Run command:
<b>php bin/magento setup:upgrade</b>
* Run Command:
<b>php bin/magento setup:static-content:deploy</b>
* Now Flush Cache: <b>php bin/magento cache:flush</b>
# Contribution
Want to contribute to this extension? The quickest way is to <a href="https://help.github.com/articles/about-pull-requests/">open a pull request</a> on GitHub.
# Support
If you encounter any problems or bugs, please <a href="https://github.com/mageprince/magento2-buynow/issues">open an issue</a> on GitHub.
<b>PRODUCT VIEW PAGE</b>
<img src="https://raw.githubusercontent.com/mageprince/all-module-screenshots/master/BuyNow/listpage.png" alt="View Page" border="0">
<b>PRODUCT LIST PAGE</b>
<img src="https://raw.githubusercontent.com/mageprince/all-module-screenshots/master/BuyNow/viewpage.png" alt="list page" border="0" />
# How To Find Addtocart Form Id - Useful For Custom Theme
Go to product view page and right click on addtocart button and click on inspect element. Then scroll up and find addtocart form id.
<img src="https://raw.githubusercontent.com/mageprince/all-module-screenshots/master/BuyNow/formid.png" alt="Form ID" border="0" />
{
"name": "mageprince/module-buynow",
"description": "Magento2 Buy Now Module",
"homepage": "https://github.com/mageprince/magento2-buynow",
"type": "magento2-module",
"version": "1.3.0",
"license": "GPL-3.0-or-later",
"authors": [
{
"name": "Prince Patel",
"email": "mail.mageprince@gmail.com"
}
],
"support": {
"issues": "https://github.com/mageprince/magento2-buynow/issues"
},
"autoload": {
"files": [
"registration.php"
],
"psr-4": {
"Mageprince\\BuyNow\\": ""
}
}
}
<?xml version="1.0"?>
<!--
/**
* MagePrince
* Copyright (C) 2020 Mageprince <info@mageprince.com>
*
* @package Mageprince_BuyNow
* @copyright Copyright (c) 2020 Mageprince (http://www.mageprince.com/)
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License,version 3 (GPL-3.0)
* @author MagePrince <info@mageprince.com>
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
<acl>
<resources>
<resource id="Magento_Backend::admin">
<resource id="Magento_Backend::stores">
<resource id="Magento_Backend::stores_settings">
<resource id="Magento_Config::config">
<resource id="Mageprince_BuyNow::config" title="Buynow Setting" sortOrder="50" />
</resource>
</resource>
</resource>
</resource>
</resources>
</acl>
</config>
<?xml version="1.0"?>
<!--
/**
* MagePrince
* Copyright (C) 2020 Mageprince <info@mageprince.com>
*
* @package Mageprince_BuyNow
* @copyright Copyright (c) 2020 Mageprince (http://www.mageprince.com/)
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License,version 3 (GPL-3.0)
* @author MagePrince <info@mageprince.com>
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="mageprince" translate="label" sortOrder="110" class="mageprince-tab">
<label>MagePrince Extensions</label>
</tab>
<section id="buynow" translate="label" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<class>separator-top</class>
<label>Buy Now</label>
<tab>mageprince</tab>
<resource>Mageprince_BuyNow::config</resource>
<group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>General Configuration</label>
<field id="keep_cart_products" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Keep Cart's Products</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>Keep Other Cart Item(s) When Click Buy Now</comment>
</field>
<field id="enable_list" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable On List Page</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="enable_view" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable On View Page</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="enable_search" translate="label" type="select" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable On Search Page</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="enable_advanced_search" translate="label" type="select" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable On Advanced Search Page</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="button_title" translate="label" type="text" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Button Title</label>
</field>
<field id="addtocart_id" translate="label" type="text" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Addtocart form Id</label>
<comment>Enter addtocart form id for product view page(Ex. product_addtocart_form). Check readme for more details.</comment>
</field>
<field id="custom_buynow_button_code" type="textarea" translate="label" sortOrder="100" showInDefault="1" showInWebsite="1">
<frontend_model>Mageprince\BuyNow\Block\Adminhtml\System\Config\Field\Disable</frontend_model>
<label>Custom Buy Now Button Code</label>
<comment><![CDATA[Change <b>$_item</b> to current product object. This code generates buy now button with new form so make sure don't copy this code into any other form.]]></comment>
</field>
</group>
</section>
</system>
</config>
<?xml version="1.0"?>
<!--
/**
* MagePrince
* Copyright (C) 2020 Mageprince <info@mageprince.com>
*
* @package Mageprince_BuyNow
* @copyright Copyright (c) 2020 Mageprince (http://www.mageprince.com/)
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License,version 3 (GPL-3.0)
* @author MagePrince <info@mageprince.com>
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<buynow>
<general>
<keep_cart_products>1</keep_cart_products>
<enable_list>1</enable_list>
<enable_view>1</enable_view>
<enable_search>1</enable_search>
<enable_advanced_search>1</enable_advanced_search>
<addtocart_id>product_addtocart_form</addtocart_id>
<button_title>Buy Now</button_title>
<custom_buynow_button_code><![CDATA[$buyNowHtml = $this->getLayout()
->createBlock('Mageprince\BuyNow\Block\Product\ListProduct')
->setProduct($_item)
->setTemplate('Mageprince_BuyNow::buynow-list.phtml')
->toHtml();
echo $buyNowHtml;]]>
</custom_buynow_button_code>
</general>
</buynow>
</default>
</config>
<?xml version="1.0"?>
<!--
/**
* MagePrince
* Copyright (C) 2020 Mageprince <info@mageprince.com>
*
* @package Mageprince_BuyNow
* @copyright Copyright (c) 2020 Mageprince (http://www.mageprince.com/)
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License,version 3 (GPL-3.0)
* @author MagePrince <info@mageprince.com>
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route id="buynow" frontName="buynow">
<module name="Mageprince_BuyNow"/>
</route>
</router>
</config>
\ No newline at end of file
<?xml version="1.0"?>
<!--
/**
* MagePrince
* Copyright (C) 2020 Mageprince <info@mageprince.com>
*
* @package Mageprince_BuyNow
* @copyright Copyright (c) 2020 Mageprince (http://www.mageprince.com/)
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License,version 3 (GPL-3.0)
* @author MagePrince <info@mageprince.com>
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">
<action name="buynow/cart/add">
<section name="cart"/>
</action>
</config>
\ No newline at end of file
<?xml version="1.0"?>
<!--
/**
* MagePrince
* Copyright (C) 2020 Mageprince <info@mageprince.com>
*
* @package Mageprince_BuyNow
* @copyright Copyright (c) 2020 Mageprince (http://www.mageprince.com/)
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License,version 3 (GPL-3.0)
* @author MagePrince <info@mageprince.com>
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Mageprince_BuyNow" setup_version="1.3.0">
<sequence>
<module name="Magento_Catalog"/>
</sequence>
</module>
</config>
\ No newline at end of file
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Mageprince_BuyNow',
__DIR__
);
<?xml version="1.0"?>
<!--
/**
* MagePrince
* Copyright (C) 2020 Mageprince <info@mageprince.com>
*
* @package Mageprince_BuyNow
* @copyright Copyright (c) 2020 Mageprince (http://www.mageprince.com/)
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License,version 3 (GPL-3.0)
* @author MagePrince <info@mageprince.com>
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="category.product.addto">
<block class="Mageprince\BuyNow\Block\Product\ListProduct"
ifconfig="buynow/general/enable_list"
name="product.buynow.list" before="-"
template="Mageprince_BuyNow::buynow-list.phtml"/>
</referenceBlock>
</body>
</page>
\ No newline at end of file
<?xml version="1.0"?>
<!--
/**
* MagePrince
* Copyright (C) 2020 Mageprince <info@mageprince.com>
*
* @package Mageprince_BuyNow
* @copyright Copyright (c) 2020 Mageprince (http://www.mageprince.com/)
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License,version 3 (GPL-3.0)
* @author MagePrince <info@mageprince.com>
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="product.info.addtocart">
<block class="Magento\Catalog\Block\Product\View"
name="product.buynow"
template="Mageprince_BuyNow::buynow-view.phtml"
before="-" ifconfig="buynow/general/enable_view"/>
</referenceBlock>
<referenceBlock name="product.info.addtocart.additional">
<block class="Magento\Catalog\Block\Product\View"
name="product.buynow.config"
template="Mageprince_BuyNow::buynow-view.phtml"
before="-" ifconfig="buynow/general/enable_view"/>
</referenceBlock>
</body>
</page>
\ No newline at end of file
<?xml version="1.0"?>
<!--
/**
* MagePrince
* Copyright (C) 2020 Mageprince <info@mageprince.com>
*
* @package Mageprince_BuyNow
* @copyright Copyright (c) 2020 Mageprince (http://www.mageprince.com/)
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License,version 3 (GPL-3.0)
* @author MagePrince <info@mageprince.com>
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="product.info.addtocart.bundle">
<block class="Magento\Catalog\Block\Product\View"
name="product.buynow"
template="Mageprince_BuyNow::buynow-view.phtml"
before="-" ifconfig="buynow/general/enable_view"/>
</referenceBlock>
</body>
</page>
<?xml version="1.0"?>
<!--
/**
* MagePrince
* Copyright (C) 2020 Mageprince <info@mageprince.com>
*
* @package Mageprince_BuyNow
* @copyright Copyright (c) 2020 Mageprince (http://www.mageprince.com/)
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License,version 3 (GPL-3.0)
* @author MagePrince <info@mageprince.com>
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<referenceBlock name="catalogsearch.product.addto">
<block class="Mageprince\BuyNow\Block\Product\ListProduct"
ifconfig="buynow/general/enable_advanced_search"
name="product.buynow.search"
before="-" template="Mageprince_BuyNow::buynow-list.phtml"/>
</referenceBlock>
</referenceContainer>
</body>
</page>
<?xml version="1.0"?>
<!--
/**
* MagePrince
* Copyright (C) 2020 Mageprince <info@mageprince.com>
*
* @package Mageprince_BuyNow
* @copyright Copyright (c) 2020 Mageprince (http://www.mageprince.com/)
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License,version 3 (GPL-3.0)
* @author MagePrince <info@mageprince.com>
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<referenceBlock name="catalogsearch.product.addto">
<block class="Mageprince\BuyNow\Block\Product\ListProduct"
ifconfig="buynow/general/enable_search"
name="product.buynow.advanced.search"
before="-" template="Mageprince_BuyNow::buynow-list.phtml"/>
</referenceBlock>
</referenceContainer>
</body>
</page>
<?php
/**
* MagePrince
* Copyright (C) 2020 Mageprince <info@mageprince.com>
*
* @package Mageprince_BuyNow
* @copyright Copyright (c) 2020 Mageprince (http://www.mageprince.com/)
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License,version 3 (GPL-3.0)
* @author MagePrince <info@mageprince.com>
*/
?>
<?php
/** @var \Mageprince\BuyNow\Block\Product\ListProduct $block */
$product = $block->getProduct();
?>
<?php $helper = $this->helper(\Mageprince\BuyNow\Helper\Data::class); ?>
<?php $buttonTitle = $helper->getButtonTitle() ?>
<?php if ($product->isSaleable()): ?>
<?php $postParams = $block->getAddToCartPostParams($product); ?>
<div class="buynow-btn">
<form action="<?= $block->escapeUrl($postParams['action']); ?>"
id="product_addtocart_form_<?= /* @noEscape */ $postParams['data']['product']; ?>"
method="post">
<input type="hidden"
name="product"
value="<?= /* @noEscape */ $postParams['data']['product']; ?>">
<input type="hidden"
name="uenc"
value="<?= /* @noEscape */ $postParams['data']['uenc']; ?>">
<?= $block->getBlockHtml('formkey') ?>
<button type="submit"
title="<?= $block->escapeHtml(__($buttonTitle)) ?>"
class="action tocart buynow primary"
data-mage-init='
{
"Mageprince_BuyNow/js/buy-now": {
"form": "#product_addtocart_form_<?= $block->escapeHtml($postParams['data']['product']) ?>"
}
}
'>
<span><?= $block->escapeHtml(__($buttonTitle)) ?></span>
</button>
</form>
</div>
<?php endif; ?>
<?php
/**
* MagePrince
* Copyright (C) 2020 Mageprince <info@mageprince.com>
*
* @package Mageprince_BuyNow
* @copyright Copyright (c) 2020 Mageprince (http://www.mageprince.com/)
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License,version 3 (GPL-3.0)
* @author MagePrince <info@mageprince.com>
*/
?>
<?php /** @var \Magento\Catalog\Block\Product\View $block */ ?>
<?php $helper = $this->helper(\Mageprince\BuyNow\Helper\Data::class); ?>
<?php $formId = $helper->getAddToCartFormId(); ?>
<?php $buttonTitle = $helper->getButtonTitle() ?>
<style>
.buy-now-btn.action.primary {
padding: 0;
display: inline;
background: none;
width:auto;
border:none;
color:#0A246A;
}
</style>
<div class="buynow-button">
<div>
<a
title="<?= $block->escapeHtml(__($buttonTitle)) ?>"
id="buy-now"
class="action primary buy-now-btn"
data-mage-init='
{
"Mageprince_BuyNow/js/buy-now": {
"form": "#<?= $block->escapeHtml($formId); ?>"
}
}
'>
<span><?= $block->escapeHtml(__($buttonTitle)) ?></span>
</a>
</div>
</div>
.catalog-category-view .actions-primary + .actions-secondary {
vertical-align: top;
}
.catalog-category-view button.buynow {
margin-left: 5px;
}
/*
.catalog-product-view #product-addtocart-button {
float: left;
}
*/
.buy-now-btn {
margin-right: 1%;
width: 49%;
line-height: 3.6rem;
}
@media(max-width: 767px){
.catalog-category-view button.buynow{
margin-top: 5px;
margin-left: 0px;
}
}
define([
'jquery'
], function ($) {
"use strict";
return function (config, element) {
$(element).click(function () {
var form = $(config.form),
baseUrl = form.attr('action'),
addToCartUrl = 'checkout/cart/add',
buyNowCartUrl = 'buynow/cart/add',
buyNowUrl = baseUrl.replace(addToCartUrl, buyNowCartUrl);
form.attr('action', buyNowUrl);
form.trigger('submit');
form.attr('action', baseUrl);
return false;
});
}
});
......@@ -50,10 +50,6 @@
width: 55px;
height: 55px;
}
span.normal-price {
float: left;
}
span.old-price.sly-old-price.no-display {
display: block !important;
float: left;
......@@ -64,6 +60,7 @@
}
.price-final_price .old-price .price{
font-size: 14px !important;
color: currentcolor;
}
</style>
<div style="width: 100%" class="product-view-freeshipping">
......
......@@ -2895,13 +2895,15 @@ button.action.submit.primary {
.page-main>.columns>.sidebar-main{
position: sticky;
top: 20%;
width: 110%;
}
.block.filter{margin-left: 10%;}
.product-info-wrapper .page-title-wrapper {
margin-left: 2%;
width: 100%;
}
.product-info-wrapper .page-title span.base{
font-size: 18px;
font-size: 28px;
padding-bottom: 1px;
margin-bottom: 0;
line-height: 0px;
......
......@@ -92,6 +92,15 @@ location ~* ^/update($|/) {
}
location / {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
if ($request_method = 'OPTIONS') {
return 204;
}
try_files $uri $uri/ /index.php$is_args$args;
}
......@@ -117,6 +126,15 @@ location /static/ {
add_header X-Frame-Options "SAMEORIGIN";
expires +1y;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
if ($request_method = 'OPTIONS') {
return 204;
}
if (!-f $request_filename) {
rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
}
......@@ -204,14 +222,11 @@ location /errors/ {
}
# PHP entry point for main application
# PHP entry point for main application
location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check)\.php$ {
try_files $uri =404;
fastcgi_pass fastcgi_backend;
# fix: upstream sent too big header
#fastcgi_buffers 1024 4k;
fastcgi_buffers 16 256k;
fastcgi_buffer_size 1024k;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
fastcgi_param PHP_VALUE "memory_limit=756M \n max_execution_time=18000";
......@@ -223,7 +238,6 @@ location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check)
include fastcgi_params;
}
gzip on;
gzip_disable "msie6";
......@@ -246,6 +260,6 @@ gzip_types
gzip_vary on;
# Banned locations (only reached if the earlier PHP entry point regexes don't match)
location ~* (\.php$|\.phtml$|\.htaccess$|\.git) {
location ~* (\.php$|\.phtml$|\.htaccess$|\.htpasswd$|\.git) {
deny all;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment