Skip to content

Commit

Permalink
Update code
Browse files Browse the repository at this point in the history
  • Loading branch information
ecoprince committed Mar 22, 2020
1 parent 59407bb commit 951cbfd
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 70 deletions.
10 changes: 0 additions & 10 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@
<label>Enable On Advanced Search Page</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="enable_related" translate="label" type="select" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable On Related Products</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>
Expand All @@ -55,12 +51,6 @@
<comment>Enter addtocart form id for product view page(Ex. product_addtocart_form)</comment>
</field>
</group>
<group id="info" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>BuyNow Button Code</label>
<field id="additional_note" translate="label" sortOrder="100" showInDefault="1" showInWebsite="1">
<frontend_model>Mageprince\BuyNow\Block\Adminhtml\System\Config\Field\AdditionalInfo</frontend_model>
</field>
</group>
</section>
</system>
</config>
Expand Down
1 change: 0 additions & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<enable_view>1</enable_view>
<enable_search>1</enable_search>
<enable_advanced_search>1</enable_advanced_search>
<enable_related>1</enable_related>
<addtocart_id>product_addtocart_form</addtocart_id>
<button_title>Buy Now</button_title>
</general>
Expand Down
2 changes: 1 addition & 1 deletion view/frontend/layout/catalog_category_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @author MagePrince <info@mageprince.com>
*/
-->
<page layout="2columns-left" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Mageprince_BuyNow::css/buynow.css"/>
</head>
Expand Down
8 changes: 1 addition & 7 deletions view/frontend/layout/catalog_product_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @author MagePrince <info@mageprince.com>
*/
-->
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Mageprince_BuyNow::css/buynow.css"/>
</head>
Expand All @@ -27,11 +27,5 @@
template="Mageprince_BuyNow::buynow-view.phtml"
before="-" ifconfig="buynow/general/enable_view"/>
</referenceBlock>
<referenceBlock name="related.product.addto">
<block class="Mageprince\BuyNow\Block\Product\ListProduct"
ifconfig="buynow/general/enable_related"
name="product.buynow.related"
before="-" template="Mageprince_BuyNow::buynow-list.phtml"/>
</referenceBlock>
</body>
</page>
2 changes: 1 addition & 1 deletion view/frontend/templates/buynow-list.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
}
}
'>
<span><?php /* @noEscape */ echo __($buttonTitle) ?></span>
<span><?= /* @noEscape */ __($buttonTitle) ?></span>
</button>
</form>
</div>
Expand Down
22 changes: 13 additions & 9 deletions view/frontend/templates/buynow-view.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@
<?php $formId = $helper->getAddToCartFormId(); ?>
<?php $buttonTitle = $helper->getButtonTitle() ?>
<div class="buynow-button">
<button type="submit" title="<?php /* @escapeNotVerified */ echo __($buttonTitle) ?>" id="buy-now" class="action primary" data-mage-init='
{
"Mageprince_BuyNow/js/buy-now": {
"form": "#<?php echo $formId; ?>"
}
}
'>
<span><?php /* @escapeNotVerified */ echo __($buttonTitle) ?></span>
<button type="submit"
title="<?= /* @escapeNotVerified */ __($buttonTitle) ?>"
id="buy-now"
class="action tocart primary"
data-mage-init='
{
"Mageprince_BuyNow/js/buy-now": {
"form": "#<?php echo $formId; ?>"
}
}
'>
<span><?= /* @escapeNotVerified */ __($buttonTitle) ?></span>
</button>
</div>
</div>
32 changes: 6 additions & 26 deletions view/frontend/web/css/buynow.css
Original file line number Diff line number Diff line change
@@ -1,38 +1,18 @@
.catalog-category-view .product-item-inner.buynow {
position: relative;
border: none;
box-shadow: none;
padding: 0 0 5px 1px;
.catalog-category-view .actions-primary + .actions-secondary {
vertical-align: top;
}

.catalog-category-view button.buynow {
width: 103px;
margin-left: 5px;
}

.catalog-product-view #product-addtocart-button {
float: left;
}

.catalog-product-view #buy-now
{
margin-bottom: 15px;
width: 49%;
line-height: 2.2rem;
padding: 14px 17px;
font-size: 1.8rem;
}

.button.buynow {
width: 100%;
margin-bottom: 10%;
}

.catalog-category-view .product.actions.product-item-actions {
margin: 0px;
}

@media(max-width: 767px){
.catalog-product-view #buy-now{
width: 100%;
.catalog-category-view button.buynow{
margin-top: 5px;
margin-left: 0px;
}
}
17 changes: 2 additions & 15 deletions view/frontend/web/js/buy-now.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,8 @@ define([
buyNowCartUrl = 'buynow/cart/add',
buyNowUrl = baseUrl.replace(addToCartUrl, buyNowCartUrl);
form.attr('action', buyNowUrl);
if(form.valid()) {
$.ajax({
type: form.attr('method'),
url: form.attr('action'),
data: form.serialize(),
success: function (data) {
form.attr('action', baseUrl);
if (data.hasOwnProperty('backUrl')) {
window.location.href = data.backUrl;
} else {
window.location.reload(true);
}
}
});
}
form.trigger('submit');
form.attr('action', baseUrl);
return false;
});
}
Expand Down

0 comments on commit 951cbfd

Please sign in to comment.