diff --git a/bin/css/order.css b/bin/css/order.css index c9a8256096e63d818cf74a7056234d65a448e31b..e9cbc59fd2faa123fde524472b259e42d9a6cfcd 100644 --- a/bin/css/order.css +++ b/bin/css/order.css @@ -149,6 +149,11 @@ td.quiqqer-order-basket-articles-article-remove button:hover { width: 150px; } +.quiqqer-order-basket-total [colspan="2"] { + font-size: 1px; + padding: 0; +} + .quiqqer-order-basket-total-sum { font-weight: bold; } diff --git a/bin/css/products.css b/bin/css/products.css index 1160b2b01fead83d4c5d2445e345ea70a849b8c0..a2555a5ccb04b06cb7ed1418a25fe33f95d5ebb1 100644 --- a/bin/css/products.css +++ b/bin/css/products.css @@ -605,7 +605,7 @@ display: inline; } -.cologne-productList-product-details-content-price .candyman-qui-products-price-display { +.cologne-productList-product-details-content-price .candyman-qui-products-price-display { display: inline; } @@ -922,8 +922,28 @@ /* button add to basket */ .product-data-actionButtons { border-top: 1px solid #f1f1f1; + display: flex; + flex-direction: column; + justify-content: flex-end; +} + +.product-data-actionButtons-buyNow { display: flex; justify-content: flex-end; + padding: 20px 20px 20px 0; + position: relative; +} + +.product-data-actionButtons-buyNow button { + flex-grow: 1; + margin: 0 0 0 20px; + position: relative; +} + +.product-data-actionButtons-buyNow-placeholder { + float: left; + margin: 0 0 0 20px; + width: 45%; } .product-data .quiqqer-order-button-add { @@ -940,9 +960,9 @@ .quiqqer-order-button-add-quantity-wrapper { display: flex; flex-direction: column; - flex-grow: 1; margin-left: 20px; margin-right: 0 !important; + width: 45%; } .quiqqer-order-button-add-quantity-wrapper .quiqqer-order-button-add-quantity { diff --git a/bin/javascript/controls/BuyNowButton.js b/bin/javascript/controls/BuyNowButton.js new file mode 100644 index 0000000000000000000000000000000000000000..1f5adf27dfa324a69953a9b8c75f2270ef1fc510 --- /dev/null +++ b/bin/javascript/controls/BuyNowButton.js @@ -0,0 +1,121 @@ +/** + * @module package/quiqqer/template-cologne/bin/javascript/controls/BuyNowButton + */ +define('package/quiqqer/template-cologne/bin/javascript/controls/BuyNowButton', [ + + 'qui/QUI', + 'qui/controls/Control', + 'package/quiqqer/order/bin/frontend/Basket', + 'package/quiqqer/order/bin/frontend/classes/Product', + 'Ajax' + +], function (QUI, QUIControl, Basket, BasketProduct, QUIAjax) { + "use strict"; + return new Class({ + + Extends: QUIControl, + Type : 'package/quiqqer/template-cologne/bin/javascript/controls/BuyNowButton', + + Binds: [ + '$addProductToBasket' + ], + + initialize: function (options) { + this.parent(options); + + this.$Input = null; + this.$Label = null; + + this.$disabled = false; + + this.addEvents({ + onImport: this.$onImport + }); + }, + + /** + * event: on import + */ + $onImport: function () { + this.getElm().addEvent('click', this.$addProductToBasket); + this.getElm().set('disabled', false); + + this.$Label = this.getElm().getElement('.add-to-basket-text'); + }, + + /** + * add the product to the basket + */ + $addProductToBasket: function () { + if (this.$disabled) { + return; + } + + this.getElm().set('disabled', true); + + var self = this, + count = null, + size = this.getElm().getSize(); + + if (this.$Input) { + count = parseInt(this.$Input.value); + } + + if (count === null) { + count = 1; + } + + this.$Label.setStyle('visibility', 'hidden'); + + var Loader = new Element('div', { + 'class': 'quiqqer-order-button-add-loader', + html : '<span class="fa fa-spinner fa-spin"></span>', + styles : { + height : '100%', + left : 0, + position : 'absolute', + top : 0, + width : '100%', + display : 'flex', + alignItems : 'center', + justifyContent: 'center' + } + }).inject(this.getElm()); + + // is the button in a product? + var fields = {}, + ProductElm = this.getElm().getParent('[data-productid]'), + ProductControl = QUI.Controls.getById(ProductElm.get('data-quiid')); + + if ("getFieldControls" in ProductControl) { + ProductControl.getFieldControls().each(function (Field) { + fields[Field.getFieldId()] = Field.getValue(); + }); + } + + var Product = new BasketProduct({ + id: ProductControl.getAttribute('productId') + }); + + Product.setFieldValues(fields).then(function () { + return Product.setQuantity(count); + }).then(function () { + return Basket.addProduct(Product); + }).then(function () { + var Span = Loader.getElement('span'); + + Span.removeClass('fa-spinner'); + Span.removeClass('fa-spin'); + + Span.addClass('success'); + Span.addClass('fa-check'); + + QUIAjax.get('package_quiqqer_order_ajax_frontend_basket_getOrderProcessUrl', function (url) { + window.location = url; + }, { + 'package': 'quiqqer/order' + }); + }.bind(this)); + } + }); +}); diff --git a/events.xml b/events.xml index 758793dbc49cc597fa69184ec061f02d6ad3ba18..45d51406f6c98efc46d4720bfd22eae7aaf70ee9 100644 --- a/events.xml +++ b/events.xml @@ -1,6 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> <events> - <event on="onProjectConfigSave" fire="\QUI\TemplateCologne\EventHandler::onProjectConfigSave" /> + <event on="onProjectConfigSave" fire="\QUI\TemplateCologne\EventHandler::onProjectConfigSave"/> <event on="onSiteSave" fire="\QUI\TemplateCologne\EventHandler::onSiteSave"/> <event on="onSmartyInit" fire="\QUI\TemplateCologne\EventHandler::onSmartyInit"/> + <event on="onQuiqqer::products::product::buttons::end" + fire="\QUI\TemplateCologne\EventHandler::onQuiqqerProductsProductButtonsEnd" + /> </events> \ No newline at end of file diff --git a/locale.xml b/locale.xml index 5d7b5ebb44712e2d92d9d3e352563dbef2a91ff1..02a30a413b8d0eaa06e359932ebd85325eeadc92 100644 --- a/locale.xml +++ b/locale.xml @@ -330,6 +330,10 @@ <de><![CDATA[Leere Produktfelder als Tab in Produktdetails ausblenden?]]></de> <en><![CDATA[Hide empty product fields as tab in product details?]]></en> </locale> + <locale name="settings.shop.showBuyNowButton"> + <de><![CDATA[Sofort Kauf Button anzeigen]]></de> + <en><![CDATA[Show Buy Now Button]]></en> + </locale> <!-- header settings --> <locale name="settings.header.title"> @@ -652,6 +656,10 @@ <en><![CDATA[Before the registration form]]></en> </locale> + <locale name="control.product.buy.know.button"> + <de><![CDATA[Jetzt kaufen]]></de> + <en><![CDATA[Buy now]]></en> + </locale> </groups> <groups name="quiqqer/template-cologne" datatype="js"> diff --git a/quiqqer/products/src/QUI/ERP/Products/Controls/Products/Product.html b/quiqqer/products/src/QUI/ERP/Products/Controls/Products/Product.html index d4f75153eda0eeb266c52186039eba08667cf17a..096ae82ced32f872d7ada2a88ea7fee48b7811d2 100644 --- a/quiqqer/products/src/QUI/ERP/Products/Controls/Products/Product.html +++ b/quiqqer/products/src/QUI/ERP/Products/Controls/Products/Product.html @@ -62,7 +62,6 @@ {$buttonsHtml} {template_event name="quiqqer::products::product::buttons::end" Product=$Product} </div> - </div> {assign var=ContentField value=$Product->getField(6)} diff --git a/settings.xml b/settings.xml index 42bc24e2126cab93ef6efe64a64a40669b1dbefb..6b4665e2760c076ced50a8027677abeb71d502f7 100644 --- a/settings.xml +++ b/settings.xml @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <quiqqer> <project> - <settings> <config> <section name="templateCologne.settings"> @@ -22,6 +21,10 @@ <type><![CDATA[bool]]></type> <defaultvalue>1</defaultvalue> </conf> + <conf name="showBuyNowButton"> + <type><![CDATA[bool]]></type> + <defaultvalue>0</defaultvalue> + </conf> <!-- header --> <conf name="headerStartPage"> @@ -169,7 +172,6 @@ <conf name="predefinedFooter.shortText.title"> <type><![CDATA[string]]></type> </conf> - </section> </config> @@ -259,6 +261,15 @@ /> </text> </input> + + + <input conf="templateCologne.settings.showBuyNowButton" type="checkbox"> + <text> + <locale group="quiqqer/template-cologne" + var="settings.shop.showBuyNowButton" + /> + </text> + </input> </settings> <!-- header --> diff --git a/src/QUI/TemplateCologne/EventHandler.php b/src/QUI/TemplateCologne/EventHandler.php index ca3f9ce3da9862b87b9f9ac3416508b7f051aefb..c63f258adfb876fadcc896504072328434c2ad4a 100644 --- a/src/QUI/TemplateCologne/EventHandler.php +++ b/src/QUI/TemplateCologne/EventHandler.php @@ -67,11 +67,35 @@ public static function onSmartyInit($Smarty) public static function fetch($params, $Smarty) { $template = $params['template']; - $path = OPT_DIR . 'quiqqer/template-cologne/'; + $path = OPT_DIR.'quiqqer/template-cologne/'; $Engine = QUI::getTemplateManager()->getEngine(); $Engine->assign($params); - return $Engine->fetch($path . $template); + return $Engine->fetch($path.$template); + } + + /** + * @param \Quiqqer\Engine\Collector $Collector + */ + public static function onQuiqqerProductsProductButtonsEnd(\Quiqqer\Engine\Collector $Collector) + { + // setting + $Project = QUI::getRewrite()->getProject(); + + if (!(int)$Project->getConfig('templateCologne.settings.showBuyNowButton')) { + return; + } + + $text = QUI::getLocale()->get('quiqqer/template-cologne', 'control.product.buy.know.button'); + + $Collector->append( + '<div class="product-data-actionButtons-buyNow"> + <div class="product-data-actionButtons-buyNow-placeholder"></div> + <button disabled data-qui="package/quiqqer/template-cologne/bin/javascript/controls/BuyNowButton"> + <span class="add-to-basket-text">'.$text.'</span> + </button> + </div>' + ); } }