możliwość przekazywania produktów w ramce + obsługiwanie dodawania do koszyka na stronie koszyka
This commit is contained in:
@@ -83,6 +83,7 @@ new IdmHotspot({
|
|||||||
* @property {string} id - Identyfikator ramki (required).
|
* @property {string} id - Identyfikator ramki (required).
|
||||||
* @property {string} title - Tytuł ramki.
|
* @property {string} title - Tytuł ramki.
|
||||||
* @property {string} classes - Dodatkowe klasy CSS.
|
* @property {string} classes - Dodatkowe klasy CSS.
|
||||||
|
* @property {object[]} [products] - tablica produktów z układem danych takich jak w graphql. Opcjonalne, pod specjalne funkcjonalności.
|
||||||
* @property {object} placement - Określa, gdzie wstawić ramkę (required).
|
* @property {object} placement - Określa, gdzie wstawić ramkę (required).
|
||||||
* @property {string} placement.selector - Selektor miejsca osadzenia.
|
* @property {string} placement.selector - Selektor miejsca osadzenia.
|
||||||
* @property {string} placement.insert - Pozycja wstawienia względem selektora (np. "afterbegin", "beforeend").
|
* @property {string} placement.insert - Pozycja wstawienia względem selektora (np. "afterbegin", "beforeend").
|
||||||
|
|||||||
30
klasa.js
30
klasa.js
@@ -149,7 +149,6 @@ const IDM_PRICE_QUERY = `price {
|
|||||||
const IDM_PRODUCT_QUERY = `id
|
const IDM_PRODUCT_QUERY = `id
|
||||||
type
|
type
|
||||||
name
|
name
|
||||||
zones
|
|
||||||
icon
|
icon
|
||||||
iconSecond
|
iconSecond
|
||||||
iconSmall
|
iconSmall
|
||||||
@@ -452,7 +451,6 @@ class IdmHotspot{
|
|||||||
|
|
||||||
this.hotspotEl = hotspotEl || null;
|
this.hotspotEl = hotspotEl || null;
|
||||||
|
|
||||||
|
|
||||||
// Merge defaults
|
// Merge defaults
|
||||||
this.options = {
|
this.options = {
|
||||||
...IdmHotspot.idmDefaultHotspotOptions.options,
|
...IdmHotspot.idmDefaultHotspotOptions.options,
|
||||||
@@ -511,6 +509,7 @@ class IdmHotspot{
|
|||||||
* Pobiera dane hotspotu z API GraphQL.
|
* Pobiera dane hotspotu z API GraphQL.
|
||||||
*/
|
*/
|
||||||
async getHotspotData(){
|
async getHotspotData(){
|
||||||
|
if(this.products) return;
|
||||||
try{
|
try{
|
||||||
const res = await fetch(`/graphql/v1/`, {
|
const res = await fetch(`/graphql/v1/`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -634,8 +633,8 @@ class IdmHotspot{
|
|||||||
markupLabel(prod){
|
markupLabel(prod){
|
||||||
let labelMarkup = ""
|
let labelMarkup = ""
|
||||||
// labele zones
|
// labele zones
|
||||||
if(prod.zones.find(zone => zone ==="bestseller")) labelMarkup += `<span class="label --bestseller --omnibus">${idmHotspotTextObject["Bestseller"]}</span>`;
|
if(prod.zones?.find(zone => zone ==="bestseller")) labelMarkup += `<span class="label --bestseller --omnibus">${idmHotspotTextObject["Bestseller"]}</span>`;
|
||||||
if(prod.zones.find(zone => zone ==="news")) labelMarkup += `<span class="label --news --omnibus">${idmHotspotTextObject["Nowość"]}</span>`;
|
if(prod.zones?.find(zone => zone ==="news")) labelMarkup += `<span class="label --news --omnibus">${idmHotspotTextObject["Nowość"]}</span>`;
|
||||||
|
|
||||||
const omnibusPrice = prod.price?.omnibusPriceDetails?.unit?.[this.idmPriceType]?.formatted || prod.price.omnibusPrice[this.idmPriceType]?.formatted;
|
const omnibusPrice = prod.price?.omnibusPriceDetails?.unit?.[this.idmPriceType]?.formatted || prod.price.omnibusPrice[this.idmPriceType]?.formatted;
|
||||||
if(omnibusPrice){
|
if(omnibusPrice){
|
||||||
@@ -829,10 +828,23 @@ class IdmHotspot{
|
|||||||
buttonEl.classList.add("--success");
|
buttonEl.classList.add("--success");
|
||||||
|
|
||||||
// Dodawanie do koszyka na stronie basketedit.php będzie wymagał innego indywidualnego kodu!!!!!
|
// Dodawanie do koszyka na stronie basketedit.php będzie wymagał innego indywidualnego kodu!!!!!
|
||||||
|
app_shop.fn?.menu_basket_cache?.();
|
||||||
|
|
||||||
|
// STRONA KOSZYKA
|
||||||
|
if(typeof app_shop.fn?.basket?.reloadForm === "function"){
|
||||||
|
const existingBasketBlockQuantity = document.querySelector(`.basket__block[data-product-id="${id}"][data-product-size="${size}"] input.buy__more_input.quantity__input[type="number"]`);
|
||||||
|
|
||||||
|
// Dodanie do ilości produktu jeśli już był dodany do koszyka
|
||||||
|
if(existingBasketBlockQuantity) existingBasketBlockQuantity.value = +existingBasketBlockQuantity.value + 1;
|
||||||
|
|
||||||
|
|
||||||
|
// Przeładowanie koszyka na stronie basketedit.html
|
||||||
|
app_shop.fn?.basket?.reloadForm();
|
||||||
|
}
|
||||||
|
|
||||||
buttonEl.innerHTML = `<span>${buttonEl.dataset.success}</span>`;
|
buttonEl.innerHTML = `<span>${buttonEl.dataset.success}</span>`;
|
||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
buttonEl.innerHTML = `<span>${buttonEl.dataset.text}</span>`;
|
buttonEl.innerHTML = `<span>${buttonEl.dataset.text}</span>`;
|
||||||
app_shop.fn?.menu_basket_cache?.();
|
|
||||||
buttonEl.classList.remove("--success");
|
buttonEl.classList.remove("--success");
|
||||||
}, 3000);
|
}, 3000);
|
||||||
}
|
}
|
||||||
@@ -1032,6 +1044,13 @@ class IdmHotspot{
|
|||||||
console.log(`Initialized hotspot #${this.id}`);
|
console.log(`Initialized hotspot #${this.id}`);
|
||||||
|
|
||||||
if(typeof this.options?.callbackFn === "function") this.options?.callbackFn();
|
if(typeof this.options?.callbackFn === "function") this.options?.callbackFn();
|
||||||
|
|
||||||
|
// WCZYTANIE PONOWNIE DLA kOSZYKA
|
||||||
|
if(typeof app_shop.fn?.basket?.reloadForm === "function" && this.hotspotEl.closest("#content")){
|
||||||
|
app_shop.run(()=>{
|
||||||
|
this.init();
|
||||||
|
}, "all", "#Basket", true)
|
||||||
|
}
|
||||||
}catch(err){
|
}catch(err){
|
||||||
console.error(idmHotspotTextObject["Wystąpił błąd z inicjalizacją. Proszę odśwież stronę"], err);
|
console.error(idmHotspotTextObject["Wystąpił błąd z inicjalizacją. Proszę odśwież stronę"], err);
|
||||||
}
|
}
|
||||||
@@ -1345,6 +1364,7 @@ function idmHideTooltip(tooltipEl){
|
|||||||
// source: {
|
// source: {
|
||||||
// productsMenu: 1649
|
// productsMenu: 1649
|
||||||
// }
|
// }
|
||||||
|
// products: [] // Tablica produktów
|
||||||
// });
|
// });
|
||||||
// {
|
// {
|
||||||
// id: "idmMainHotspot2",
|
// id: "idmMainHotspot2",
|
||||||
|
|||||||
@@ -5,10 +5,10 @@
|
|||||||
- zakres cen?????????????
|
- zakres cen?????????????
|
||||||
- Wybór kolorystyczny???
|
- Wybór kolorystyczny???
|
||||||
- AAAAA - banner na hotspocie
|
- AAAAA - banner na hotspocie
|
||||||
- opinie
|
|
||||||
- podmiana zdjęcia na hover
|
- podmiana zdjęcia na hover
|
||||||
- stary szablon
|
- stary szablon
|
||||||
- cena za kg
|
- cena za kg
|
||||||
|
- blokowanie dodawania do koszyka jeśli ilość jest maksymalna
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user