diff --git a/templates/local_shopping_cart/shopping_cart_popover.mustache b/templates/local_shopping_cart/shopping_cart_popover.mustache new file mode 100644 index 0000000..700b07d --- /dev/null +++ b/templates/local_shopping_cart/shopping_cart_popover.mustache @@ -0,0 +1,161 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template local_shopping_cart/shopping_cart_popover + + This template will render the shopping_cart popover for the navigation bar. + + Classes required for JS: + * none + + Data attributes required for JS: + * All data attributes are required + + Context variables required for this template: + * userid the logged in user id + * urls The URLs for the popover + + Example context (json): + { + "count":1, + "maxitems":"10", + "items":[ + { + "id":"2", + "userid":"2309", + "itemid":"1", + "itemname":"my test item 1", + "price":"10.00", + "discount":"0.00", + "currency":"EUR", + "componentname":"local_shopping_cart", + "area": "main", + "identifier":"1668028796", + "payment":"3", + "paymentstatus":"2", + "usermodified":"2", + "timecreated":"1668028796", + "timemodified":"1668028796", + "canceluntil":"1669238377", + "serviceperiodstart":"0", + "serviceperiodend":"0", + "gateway":null, + "date":"2022-11-09", + "canceled":false, + "canceluntilstring":"2022-11-23", + "canceluntilalert":"Stornieren ist nicht m\u00f6glich.", + "buttonclass":"disabled hidden", + "paymentstring":"in bar an der Kassa" + } + ], + "price":0, + "initialtotal":0, + "deductible":0, + "checkboxid":"af7a6b", + "usecredit":1, + "expirationtime":1667988637, + "nowdate":1667988637, + "checkouturl":"http:\/\/localhost\/400_moodle\/local\/shopping_cart\/checkout.php", + "currency":"EUR", + "credit":0, + "remainingcredit":0, + "buyforuserid":3588, + "userid":3588, + "userlastname":"Faulkner", + "userfirstname":"Graiden", + "useremail":"Graiden.Faulkner@mailinator.com", + "historyitems":[ + { + "id":"2", + "userid":"2309", + "itemid":"1", + "itemname":"my test item 1", + "price":"10.00", + "discount":"0.00", + "currency":"EUR", + "componentname":"local_shopping_cart", + "area": "main", + "identifier":"1668028796", + "payment":"3", + "paymentstatus":"2", + "usermodified":"2", + "timecreated":"1668028796", + "timemodified":"1668028796", + "canceluntil":"1669238377", + "serviceperiodstart":"0", + "serviceperiodend":"0", + "gateway":null, + "date":"2022-11-09", + "canceled":false, + "canceluntilstring":"2022-11-23", + "canceluntilalert":"Stornieren ist nicht m\u00f6glich.", + "buttonclass":"disabled hidden", + "paymentstring":"in bar an der Kassa" + } + ], + "canpayback":true, + "additonalcashiersection":"
..<\/div>", + "wwwroot":"http:\/\/localhost\/400_moodle", + "users":"[\"Caldwell Illana (Illana.Caldwell@mailinator.com) vatnr:512\",\"Ferguson Desirae (Desirae.Ferguson@mailinator.com) vatnr:768\",\"Lindsey Rose (Rose.Lindsey@example.com) vatnr:1024\",\"Oneil Octavius (Octavius.Oneil@example.com) vatnr:1280\",\"Franklin Francis (Francis.Franklin@example.com) vatnr:1536\"]", + "mail":"Graiden.Faulkner@mailinator.com", + "name":"Graiden Faulkner" + } + +}} + +{{< core/popover_region }} + {{$classes}}popover-region-shopping_carts{{/classes}} + {{$attributes}}id="nav-shopping_cart-popover-container" data-userid="{{userid}}"{{/attributes}} + + {{$togglelabel}}{{/togglelabel}} + {{$togglecontent}} + +
{{count}}
+ {{/togglecontent}} + + {{$containerlabel}}{{/containerlabel}} + + {{$headertext}} + + [{{expirationtime}}] + {{/headertext}} + {{$content}} +

{{#str}} mycart, local_shopping_cart {{/str}}

+
+ {{> local_shopping_cart/shopping_cart_items }} +
+ {{> local_shopping_cart/checkout_button }} + {{/content}} +{{/ core/popover_region }} + +{{#showcashier}} + +{{/showcashier}} + +{{#js}} + require(['core/popover_region_controller', 'core/ajax', 'local_shopping_cart/cart'], function(Сontroller, Ajax, cart) { + cart.init({{expirationtime}}, {{nowdate}}); + let sccontainer = document.querySelector('#nav-shopping_cart-popover-container'); + let sccontroller = new Сontroller(sccontainer); + sccontroller.registerListNavigationEventListeners(); + }); +{{/js}}