had to marge repos
This commit is contained in:
commit
ee58c5db82
14
.gitignore
vendored
Normal file
14
.gitignore
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
*
|
||||
|
||||
!.gitignore
|
||||
|
||||
!plugins/
|
||||
!themes/
|
||||
|
||||
plugins/*
|
||||
!plugins/pandaGadzety/
|
||||
!plugins/pandaGadzety/**
|
||||
|
||||
themes/*
|
||||
!themes/pandaTheme/
|
||||
!themes/pandaTheme/**
|
||||
0
plugins/pandaGadzety/assets/css/calculator.css
Normal file
0
plugins/pandaGadzety/assets/css/calculator.css
Normal file
31
plugins/pandaGadzety/assets/css/delivery.css
Normal file
31
plugins/pandaGadzety/assets/css/delivery.css
Normal file
@ -0,0 +1,31 @@
|
||||
#delivery-tab {
|
||||
width: 100%
|
||||
}
|
||||
|
||||
#delivery-tab table {
|
||||
width: 100%
|
||||
}
|
||||
|
||||
#delivery-tab table tr {
|
||||
border: 1px solid #00b4e1;
|
||||
}
|
||||
|
||||
#delivery-tab table tr th {
|
||||
background-color: #00b4e1;
|
||||
color: white;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
#delivery-tab table tr td {
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
#delivery-tab table tr th, #delivery-tab table tr td {
|
||||
border: 1px solid #00b4e1;
|
||||
}
|
||||
|
||||
#delivery-tab h2 {
|
||||
color: #00b4e1;
|
||||
font-weight: bold;
|
||||
margin-top: 20px;
|
||||
}
|
||||
31
plugins/pandaGadzety/assets/css/description.css
Normal file
31
plugins/pandaGadzety/assets/css/description.css
Normal file
@ -0,0 +1,31 @@
|
||||
#description-tab {
|
||||
width: 100%
|
||||
}
|
||||
|
||||
#description-tab table {
|
||||
width: 100%
|
||||
}
|
||||
|
||||
#description-tab table tr {
|
||||
border: 1px solid #00b4e1;
|
||||
}
|
||||
|
||||
#description-tab table tr th {
|
||||
background-color: #00b4e1;
|
||||
color: white;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
#description-tab table tr td {
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
#description-tab table tr th, #description-tab table tr td {
|
||||
border: 1px solid #00b4e1;
|
||||
}
|
||||
|
||||
#description-tab h2 {
|
||||
color: #00b4e1;
|
||||
font-weight: bold;
|
||||
margin-top: 20px;
|
||||
}
|
||||
12
plugins/pandaGadzety/assets/css/hidden-add-to-cart.css
Normal file
12
plugins/pandaGadzety/assets/css/hidden-add-to-cart.css
Normal file
@ -0,0 +1,12 @@
|
||||
form.cart {
|
||||
/* display: none; */
|
||||
}
|
||||
|
||||
.wp-block-add-to-cart-form, .wc-block-add-to-cart-form, .wp-block-post-excerpt {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.summary > .price {
|
||||
display: none;
|
||||
}
|
||||
|
||||
10
plugins/pandaGadzety/assets/css/labeling-description.css
Normal file
10
plugins/pandaGadzety/assets/css/labeling-description.css
Normal file
@ -0,0 +1,10 @@
|
||||
.labeling-description-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.labeling-description-box img {
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
padding: 20px;
|
||||
}
|
||||
8
plugins/pandaGadzety/assets/css/labeling.css
Normal file
8
plugins/pandaGadzety/assets/css/labeling.css
Normal file
@ -0,0 +1,8 @@
|
||||
#labeling {
|
||||
|
||||
}
|
||||
|
||||
#labeling img {
|
||||
width: 200px;
|
||||
margin: 50px;
|
||||
}
|
||||
17
plugins/pandaGadzety/assets/js/archive-images.js
Normal file
17
plugins/pandaGadzety/assets/js/archive-images.js
Normal file
@ -0,0 +1,17 @@
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
if (!archiveImagesData || !archiveImagesData.products) return;
|
||||
|
||||
const products = document.querySelectorAll(".product[data-sku]");
|
||||
|
||||
products.forEach(product => {
|
||||
const sku = product.dataset.sku;
|
||||
const productInfo = archiveImagesData.products[sku];
|
||||
|
||||
if (productInfo && productInfo.img) {
|
||||
const img = product.querySelector("img")
|
||||
img.src = productInfo.img;
|
||||
img.srcset = productInfo.img;
|
||||
img.alt = sku;
|
||||
}
|
||||
});
|
||||
});
|
||||
470
plugins/pandaGadzety/assets/js/calculator.js
Normal file
470
plugins/pandaGadzety/assets/js/calculator.js
Normal file
@ -0,0 +1,470 @@
|
||||
/**
|
||||
* Class to display product labeling and pacing options
|
||||
*/
|
||||
class PandaCalculator {
|
||||
|
||||
positions = {};
|
||||
productInfo;
|
||||
productPrice;
|
||||
|
||||
constructor(productInfo) {
|
||||
this.productInfo = productInfo;
|
||||
this.productPrice = calculatorScriptVariables.productInfo.productBaseInfo.price;
|
||||
this.#decodeLabeling();
|
||||
|
||||
}
|
||||
|
||||
init(optionDiv, technologyDiv, imageDiv, totalPrice) {
|
||||
|
||||
document.querySelector("#attributes").innerHTML = this.#drawAttributes();
|
||||
document.querySelector(optionDiv).innerHTML = this.#drawPositionSelect();
|
||||
|
||||
this.#updatePrice(totalPrice);
|
||||
|
||||
document.querySelector("#select_options").addEventListener("change", () => {
|
||||
document.querySelector(technologyDiv).innerHTML = this.#drawTechnologySelect();
|
||||
|
||||
// this.#updatePrice(totalPrice);
|
||||
|
||||
document.querySelector("#select_technology").addEventListener("change", () => {
|
||||
if (document.querySelector("#select_technology").value != "brak") {
|
||||
document.querySelector(imageDiv).innerHTML = this.#getImage();
|
||||
let value = this.#getSelectedOptions();
|
||||
if (value) {
|
||||
|
||||
let maxColors = value.max_colors;
|
||||
let dimensions = { "width": value.max_width, "height": value.max_height, "radius": value.max_radius } ;
|
||||
this.#getColorNumber(maxColors);
|
||||
this.#showDemission(dimensions);
|
||||
|
||||
this.#updatePrice(totalPrice);
|
||||
|
||||
const colorInput = document.querySelector("#color_number_input");
|
||||
if (colorInput) {
|
||||
colorInput.addEventListener("change", () => {
|
||||
this.#updatePrice(totalPrice);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
|
||||
document.querySelector("#quantity").addEventListener("change", (event) => {
|
||||
this.#updatePrice(totalPrice);
|
||||
})
|
||||
|
||||
//this.#updatePriceDefaultBDI();
|
||||
}
|
||||
|
||||
#updatePrice(totalPrice) {
|
||||
let sumPrice = this.#getPricingTable();
|
||||
document.querySelector(totalPrice).innerHTML = sumPrice;
|
||||
document.getElementsByName("total_price")[0].value = sumPrice;
|
||||
// document.getElementsByName("product_price")[0].value = this.productPrice;
|
||||
}
|
||||
|
||||
|
||||
#decodeLabeling() {
|
||||
this.productInfo.labeling.forEach(element => {
|
||||
this.positions[element.name] = this.positions[element.name] ? this.positions[element.name].concat(element) : [element]
|
||||
});
|
||||
}
|
||||
|
||||
#drawPositionSelect() {
|
||||
var html = "<select id='select_options' name='option'>";
|
||||
html += "<option value='brak'>Bez znakowania</option>";
|
||||
Object.keys(this.positions).forEach(key => {
|
||||
html += "<option value='" + key + "'>" + key +"</option>";
|
||||
})
|
||||
html += "</select>";
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
#drawTechnologySelect() {
|
||||
var html = "";
|
||||
|
||||
var positionKey = document.querySelector("#select_options").value;
|
||||
|
||||
if (positionKey != "brak") {
|
||||
html += "<p>Technologia znakowania</p>";
|
||||
html += "<select id='select_technology' name='technology'>";
|
||||
html += "<option value='brak'>Wybierz technikę znakowania</option>";
|
||||
Object.keys(this.positions[positionKey]).forEach(key => {
|
||||
let value = this.positions[positionKey][key];
|
||||
let size = value.max_radius != "0" ? "(" + value.max_radius + "mm)" : "(" + value.max_height + "mm x " + value.max_height + "mm)";
|
||||
html += "<option value='" + value.technology + "'>" + value.technology + " " + size + "</option>";
|
||||
})
|
||||
html += "</select>";
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
#drawAttributes() {
|
||||
let html = "";
|
||||
|
||||
const attributes = this.productInfo.productBaseInfo.attributes || {};
|
||||
|
||||
if (Object.keys(attributes).length === 0) {
|
||||
return html;
|
||||
}
|
||||
|
||||
Object.keys(attributes).forEach(key => {
|
||||
html += `<label>`;
|
||||
html += `<p>${key}</p>`;
|
||||
html += `<select id='select_attributes_${key}' name='${key}'>`;
|
||||
attributes[key].forEach(value => {
|
||||
html += `<option value='${value.attributes}'>${value.attributes}</option>`;
|
||||
});
|
||||
html += `</select>`;
|
||||
html += `</label>`;
|
||||
});
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
|
||||
#getImage() {
|
||||
|
||||
var value = this.#getSelectedOptions();
|
||||
|
||||
if (value.image) {
|
||||
var html = "<img src='" + value.image +"' />";
|
||||
return html;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
#getPricingTable() {
|
||||
|
||||
let quantity = document.querySelector("#quantity").value ? document.querySelector("#quantity").value : 1;
|
||||
let productPrice = this.#getBulkPrice(parseFloat(this.productPrice), quantity);
|
||||
|
||||
document.getElementsByName("product_price")[0].value = productPrice;
|
||||
document.querySelector("#product_price").innerHTML = productPrice;
|
||||
|
||||
var unitPrice = 0;
|
||||
var setupCost = 0;
|
||||
|
||||
if (document.querySelector("#select_options") && document.querySelector("#select_technology")) {
|
||||
|
||||
let value = this.#getSelectedOptions();
|
||||
|
||||
// console.log(value);
|
||||
|
||||
var colorNumber = document.querySelector("#color_number_input") ? document.querySelector("#color_number_input").value : 1;
|
||||
// console.log(colorNumber);
|
||||
// console.log(value);
|
||||
if (value.max_colors == 0 && Object.keys(value.pricing)[0] == "fullcolour") {
|
||||
colorNumber = "fullcolour";
|
||||
}
|
||||
|
||||
if (value.pricing && value.pricing[colorNumber]) {
|
||||
|
||||
var unitPrice = value.pricing[colorNumber].unit_price
|
||||
var setupCost = value.pricing[colorNumber].setup_cost
|
||||
value.pricing[colorNumber].forEach((element) => {
|
||||
if (
|
||||
parseInt(element.quantity_from) <= parseInt(quantity)
|
||||
&& parseInt(element.quantity_to) >= parseInt(quantity)
|
||||
) {
|
||||
unitPrice = element.unit_price
|
||||
setupCost = element.setup_cost
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
document.querySelector("#price").innerHTML = unitPrice;
|
||||
document.querySelector("#setup_price").innerHTML = setupCost;
|
||||
document.getElementsByName("labeling_price")[0].value = unitPrice;
|
||||
document.getElementsByName("setup_price")[0].value = setupCost;
|
||||
let sum = (parseFloat(productPrice) * quantity) + (parseFloat(unitPrice) * quantity) + parseFloat(setupCost);
|
||||
|
||||
return Math.round(sum * 100) / 100;
|
||||
}
|
||||
|
||||
|
||||
#getSelectedOptions() {
|
||||
var positionKey = document.querySelector("#select_options").value;
|
||||
var technologyKey = document.querySelector("#select_technology").value;
|
||||
|
||||
// console.log(technologyKey);
|
||||
// console.log(positionKey);
|
||||
|
||||
if (technologyKey != "brak") {
|
||||
|
||||
var position = this.positions[positionKey];
|
||||
|
||||
for (let index = 0; index < position.length; index++) {
|
||||
if (position[index].technology == technologyKey) {
|
||||
var value = position[index]
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
|
||||
}
|
||||
|
||||
#getColorNumber(maxColor) {
|
||||
|
||||
|
||||
if (maxColor != 0) {
|
||||
var html = `<label>`;
|
||||
html += `<p>Ilość kolorów</p>`;
|
||||
html += `<input type='number' max='${maxColor}' min='1' value='1' name='colors' id='color_number_input'/>`;
|
||||
html += "</label>";
|
||||
} else {
|
||||
var html = `<label>`;
|
||||
html += `<p>Ilość kolorów</p>`;
|
||||
html += `<input type='number' max='1' min='1' value='1' name='colors' id='color_number_input'/>`;
|
||||
html += "</label>";
|
||||
}
|
||||
|
||||
document.querySelector("#color_number").innerHTML = html;
|
||||
}
|
||||
|
||||
#showDemission(dimensions) {
|
||||
let demission = "";
|
||||
if (dimensions.radius == "0") {
|
||||
demission += dimensions.width + "mm x " + dimensions.height + "mm";
|
||||
} else {
|
||||
demission += dimensions.radius + "mm";
|
||||
}
|
||||
|
||||
document.querySelector("#dimensions_name").innerHTML = "Wymiary nadruku:";
|
||||
document.querySelector("#dimensions").innerHTML = demission;
|
||||
}
|
||||
|
||||
#updatePriceDefaultBDI() {
|
||||
let currencySymbol = document.querySelector('.woocommerce-Price-currencySymbol').innerHTML;
|
||||
let priceBox = document.querySelector('.woocommerce-Price-amount');
|
||||
priceBox.innerHTML = " 0.00";
|
||||
|
||||
}
|
||||
|
||||
#getBulkPrice(price, quantity) {
|
||||
var newPrice = price;
|
||||
if (price < 5) {
|
||||
if (quantity >= 1 && quantity <= 9) {
|
||||
newPrice = price + price * 0.36;
|
||||
} else if (quantity >= 10 && quantity <= 249) {
|
||||
newPrice = price - price * 0.31;
|
||||
} else if (quantity >= 250 && quantity <= 999) {
|
||||
newPrice = price - price * 0.37;
|
||||
} else if (quantity >= 1000 && quantity <= 4999) {
|
||||
newPrice = price - price * 0.42;
|
||||
} else if (quantity >= 5000) {
|
||||
newPrice = price - price * 0.47;
|
||||
}
|
||||
} else {
|
||||
if (quantity >= 1 && quantity <= 9) {
|
||||
newPrice = price;
|
||||
} else if (quantity >= 10 && quantity <= 99) {
|
||||
newPrice = price - price * 0.31;
|
||||
} else if (quantity >= 100 && quantity <= 249) {
|
||||
newPrice = price - price * 0.37;
|
||||
} else if (quantity >= 250 && quantity <= 999) {
|
||||
newPrice = price - price * 0.42;
|
||||
} else if (quantity >= 1000) {
|
||||
newPrice = price - price * 0.47;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
newPrice = Math.round(newPrice * 100) / 100;
|
||||
return newPrice;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class ShowInformation {
|
||||
constructor() {
|
||||
let base = calculatorScriptVariables.productInfo.productBaseInfo
|
||||
|
||||
let price = base.price;
|
||||
//let currencySymbol = document.querySelector(".woocommerce-Price-currencySymbol").innerHTML;
|
||||
//document.querySelector("bdi").innerHTML = price + currencySymbol;
|
||||
|
||||
console.log(calculatorScriptVariables.productInfo)
|
||||
|
||||
const invent = calculatorScriptVariables.productInfo.inventory
|
||||
const attributes = document.getElementById("select_attributes_color")
|
||||
if(!attributes) {
|
||||
if(invent.length == 0) {
|
||||
document.getElementById("stock").innerHTML = "Ilość w magazynie " + 0 + " szt."
|
||||
document.getElementById("add_to_cart_button").disabled = true;
|
||||
document.getElementById("add_to_cart_button").value = "Niedostępne";
|
||||
document.getElementById("add_to_cart_button").classList.add("unavailable");
|
||||
}
|
||||
|
||||
invent.forEach(inv => {
|
||||
if(inv.type === "central_stock") {
|
||||
document.getElementById("stock").innerHTML = "Ilość w magazynie " + inv.amount + " szt."
|
||||
if (inv.amount < 50) {
|
||||
document.getElementById("add_to_cart_button").disabled = true;
|
||||
document.getElementById("add_to_cart_button").value = "Niedostępne";
|
||||
document.getElementById("add_to_cart_button").classList.add("unavailable");
|
||||
} else {
|
||||
document.getElementById("add_to_cart_button").disabled = false;
|
||||
document.getElementById("add_to_cart_button").value = "Dodaj do koszyka";
|
||||
document.getElementById("add_to_cart_button").classList.remove("unavailable");
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
} else {
|
||||
const color = attributes.value;
|
||||
const selectedColor = calculatorScriptVariables.productInfo.productBaseInfo.attributes.color.find(c => {
|
||||
return c.attributes === color;
|
||||
});
|
||||
|
||||
const sku = selectedColor.image.split('/').at(-1).split('.')[0]
|
||||
const invent = calculatorScriptVariables.productInfo.inventory
|
||||
|
||||
invent.forEach(inv => {
|
||||
if(inv.type === "central_stock" && inv.sku == sku) {
|
||||
document.getElementById("stock").innerHTML = "Ilość w magazynie " + inv.amount + " szt."
|
||||
if (inv.amount < 50) {
|
||||
document.getElementById("add_to_cart_button").disabled = true;
|
||||
document.getElementById("add_to_cart_button").value = "Niedostępne";
|
||||
document.getElementById("add_to_cart_button").classList.add("unavailable");
|
||||
} else {
|
||||
document.getElementById("add_to_cart_button").disabled = false;
|
||||
document.getElementById("add_to_cart_button").value = "Dodaj do koszyka";
|
||||
document.getElementById("add_to_cart_button").classList.remove("unavailable");
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const gallery = document.querySelector(".single-product__images");
|
||||
const images = calculatorScriptVariables.productInfo.productBaseInfo.images
|
||||
|
||||
if(images) {
|
||||
|
||||
images.forEach(img => {
|
||||
const url = img.url;
|
||||
|
||||
const imageElement = document.createElement("img");
|
||||
imageElement.src = url;
|
||||
imageElement.alt = "Obraz produktu";
|
||||
imageElement.classList.add("product-image");
|
||||
|
||||
imageElement.addEventListener("click", () => {
|
||||
const thumbnail = document.querySelector(".single-product__thumbnails img");
|
||||
thumbnail.src = url;
|
||||
})
|
||||
|
||||
gallery.appendChild(imageElement);
|
||||
});
|
||||
|
||||
|
||||
jQuery(function($) {
|
||||
$('.single-product__images').slick({
|
||||
slidesToShow: images.length,
|
||||
slidesToScroll: 1,
|
||||
arrows: true,
|
||||
infinite: true,
|
||||
adaptiveHeight: false,
|
||||
draggable: false,
|
||||
swipe: false,
|
||||
prevArrow: '<button type="button" class="slick-prev slider-arrow"><span class="screen-reader-text">Poprzedni</span></button>',
|
||||
nextArrow: '<button type="button" class="slick-next slider-arrow"><span class="screen-reader-text">Następny</span></button>',
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
const photo = base.primary_img;
|
||||
if (photo) {
|
||||
const thumbnailContainer = document.querySelector(".single-product__thumbnails");
|
||||
|
||||
const img = document.createElement("img");
|
||||
img.src = photo;
|
||||
img.alt = "Podgląd produktu";
|
||||
img.style.borderRadius = "8px";
|
||||
|
||||
thumbnailContainer.appendChild(img);
|
||||
}
|
||||
|
||||
const nameDiv = document.getElementById("product-name")
|
||||
const infoCard = document.querySelector(".product-info-card__header h2")
|
||||
nameDiv.innerHTML = infoCard.innerHTML
|
||||
|
||||
const selectColor = document.getElementById("select_attributes_color")
|
||||
|
||||
if(selectColor) {
|
||||
selectColor.addEventListener("change", this.colorChanged)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
colorChanged(e) {
|
||||
const color = e.target.value;
|
||||
|
||||
const selectedColor = calculatorScriptVariables.productInfo.productBaseInfo.attributes.color.find(c => {
|
||||
return c.attributes === color;
|
||||
});
|
||||
|
||||
if (!selectedColor) {
|
||||
console.warn("Nie znaleziono koloru:", color);
|
||||
return;
|
||||
}
|
||||
|
||||
const img = document.createElement("img");
|
||||
img.src = selectedColor.image;
|
||||
img.alt = "Podgląd produktu";
|
||||
img.style.borderRadius = "8px";
|
||||
|
||||
const photoContainer = document.getElementById("attributes-photo");
|
||||
photoContainer.innerHTML = "";
|
||||
photoContainer.appendChild(img);
|
||||
|
||||
const sku = selectedColor.image.split('/').at(-1).split('.')[0]
|
||||
|
||||
const invent = calculatorScriptVariables.productInfo.inventory
|
||||
|
||||
invent.forEach(inv => {
|
||||
if(inv.type === "central_stock" && inv.sku == sku) {
|
||||
document.getElementById("stock").innerHTML = "Ilość w magazynie " + inv.amount + " szt."
|
||||
if (inv.amount < 50) {
|
||||
document.getElementById("add_to_cart_button").disabled = true;
|
||||
document.getElementById("add_to_cart_button").value = "Niedostępne";
|
||||
document.getElementById("add_to_cart_button").classList.add("unavailable");
|
||||
} else {
|
||||
document.getElementById("add_to_cart_button").disabled = false;
|
||||
document.getElementById("add_to_cart_button").value = "Dodaj do koszyka";
|
||||
document.getElementById("add_to_cart_button").classList.remove("unavailable");
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
var productCalculator = new PandaCalculator(calculatorScriptVariables.productInfo);
|
||||
productCalculator.init("#options", "#technology", "#select_image", '#total_price');
|
||||
|
||||
var information = new ShowInformation();
|
||||
});
|
||||
20
plugins/pandaGadzety/assets/js/slider-images.js
Normal file
20
plugins/pandaGadzety/assets/js/slider-images.js
Normal file
@ -0,0 +1,20 @@
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
if (!archiveImagesData || !archiveImagesData.products) return;
|
||||
|
||||
const slides = document.querySelectorAll("[data-sku]");
|
||||
|
||||
slides.forEach(slide => {
|
||||
const sku = slide.dataset.sku;
|
||||
const productInfo = archiveImagesData.products[sku];
|
||||
|
||||
if (productInfo && productInfo.img) {
|
||||
const img = slide.querySelector("img");
|
||||
|
||||
if (img) {
|
||||
img.src = productInfo.img;
|
||||
img.srcset = productInfo.img;
|
||||
img.alt = sku;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Foxstudio\Plugins\Template\Controller;
|
||||
use Foxstudio\Plugins\Template\Utils as Utils;
|
||||
use Foxstudio\Plugins\Template\Repository as Repository;
|
||||
|
||||
class CalculatorController {
|
||||
|
||||
public function __construct() {
|
||||
|
||||
\add_menu_page(
|
||||
'myId',
|
||||
'myId',
|
||||
'manage_options',
|
||||
PLUGIN_URL_DIR,
|
||||
[$this, 'settings_page'],
|
||||
plugins_url('assets/img/icon.png', PLUGIN_URL)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public function settings_page() {
|
||||
|
||||
$product_repository = new Repository\ProductRepository(SERVER_URL);
|
||||
$results = $product_repository->getProductInfo("AP800450");
|
||||
|
||||
var_dump($results['message']);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Foxstudio\Plugins\Template\Controller;
|
||||
use Foxstudio\Plugins\Template\Utils as Utils;
|
||||
|
||||
|
||||
class ProductDetailsController {
|
||||
private $productBaseInfo;
|
||||
private $labeling;
|
||||
private $inventory;
|
||||
public function __construct() {
|
||||
// $this->load();
|
||||
// \add_action('woocommerce_before_single_product', [$this, 'load']);
|
||||
|
||||
new Utils\DeliveryTab();
|
||||
new Utils\LabelingTab();
|
||||
new Utils\LabelingDescriptionTab();
|
||||
new Utils\ProductDescriptionTab();
|
||||
new Utils\PriceCalculator();
|
||||
}
|
||||
|
||||
public function load() {
|
||||
// global $product;
|
||||
// $sku = $product->get_sku();
|
||||
|
||||
// if(!empty($sku)) {
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
50
plugins/pandaGadzety/controller/plugins-controller.php
Normal file
50
plugins/pandaGadzety/controller/plugins-controller.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Foxstudio\Plugins\Template\Controller;
|
||||
use Foxstudio\Plugins\Template\Controller as Controller;
|
||||
use Foxstudio\Plugins\Template\Utils as Utils;
|
||||
use Foxstudio\Plugins\Template\Interface\PluginsControllerInterface;
|
||||
|
||||
class PluginsController implements PluginsControllerInterface
|
||||
{
|
||||
|
||||
private \WP_User $user;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->user = \wp_get_current_user();
|
||||
|
||||
\register_activation_hook(PLUGIN_URL, [$this, 'activationPlugins']);
|
||||
\register_deactivation_hook(PLUGIN_URL, [$this, 'disablePlugins']);
|
||||
\add_action('init', [$this, 'declarePlugins']);
|
||||
|
||||
}
|
||||
|
||||
public function activationPlugins(): void {
|
||||
// Perform activation tasks if needed
|
||||
}
|
||||
|
||||
public function declarePlugins(): void {
|
||||
if(\is_plugin_active(BASE_NAME . "/pandaGadzety.php")) {
|
||||
|
||||
new Utils\InformationAboutLabeling();
|
||||
new Utils\InformationAboutLabelingMixed();
|
||||
new Controller\CalculatorController();
|
||||
new Controller\ProductDetailsController();
|
||||
new Utils\LogisticMinimum(350, 45);
|
||||
new Utils\ShowMinimumPrice();
|
||||
|
||||
|
||||
// var_dump(wc()->session->get_session_cookie());
|
||||
}
|
||||
}
|
||||
|
||||
public function disablePlugins(): void {
|
||||
// Perform activation tasks if needed
|
||||
}
|
||||
|
||||
public function updatePlugins(): void {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Foxstudio\Plugins\Template\Interface;
|
||||
|
||||
interface PluginsControllerInterface
|
||||
{
|
||||
public function activationPlugins(): void;
|
||||
public function declarePlugins(): void;
|
||||
public function disablePlugins(): void;
|
||||
public function updatePlugins(): void;
|
||||
}
|
||||
61
plugins/pandaGadzety/pandaGadzety.php
Normal file
61
plugins/pandaGadzety/pandaGadzety.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Plugin Name: Panda gadżety
|
||||
* Description: Handle the basics with this plugin.
|
||||
* Version: 1.0.0
|
||||
* Requires at least: 5.2
|
||||
* Requires PHP: 7.2
|
||||
* Author: Foxstudio
|
||||
* Author URI: https://foxstudio.info/
|
||||
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* Update URI: https://example.com/my-plugin/
|
||||
* Text Domain: Wtyczka dodająca wsparcie produktów
|
||||
* Domain Path: /languages
|
||||
*/
|
||||
|
||||
namespace Foxstudio\Plugins\Template;
|
||||
|
||||
define("PLUGIN_URL", __FILE__);
|
||||
define("PLUGIN_URL_DIR", untrailingslashit(dirname(PLUGIN_URL)));
|
||||
define("BASE_NAME", dirname(plugin_basename(__FILE__)));
|
||||
define("API_KEY", "a8b83f8432b6d0eb4dc9432b4eefc3989d759bd9ac20");
|
||||
// define("SERVER_URL", "http://webpage");
|
||||
define("SERVER_URL", "http://51.68.141.253:2001");
|
||||
|
||||
// Wordpress
|
||||
require_once ABSPATH . 'wp-includes/pluggable.php';
|
||||
|
||||
// Repository
|
||||
require_once __DIR__ . "/repository/get_product_info.php";
|
||||
|
||||
|
||||
// Interface
|
||||
require_once __DIR__ . "/interface/plugins-controller-interface.php";
|
||||
|
||||
// utils
|
||||
require_once __DIR__ . "/utils/load-file.php";
|
||||
require_once __DIR__ . "/utils/delivery-tab.php";
|
||||
require_once __DIR__ . "/utils/labeling-tab.php";
|
||||
require_once __DIR__ . "/utils/labeling-description-tab.php";
|
||||
require_once __DIR__ . "/utils/product-description-tab.php";
|
||||
require_once __DIR__ . "/utils/product-calculator.php";
|
||||
require_once __DIR__ . "/utils/logistic-minimum.php";
|
||||
require_once __DIR__ . "/utils/modify-product-name.php";
|
||||
require_once __DIR__ . "/utils/information-about-realization.php";
|
||||
require_once __DIR__ . "/utils/information-about-labeling-mixed.php";
|
||||
require_once __DIR__ . "/utils/notice.php";
|
||||
|
||||
|
||||
// Controller
|
||||
require_once __DIR__ . "/controller/plugins-controller.php";
|
||||
require_once __DIR__ . "/controller/panda-calculator-controller.php";
|
||||
require_once __DIR__ . "/controller/panda-product-details-loader.php";
|
||||
|
||||
// Init plugins
|
||||
function initPlugin()
|
||||
{
|
||||
new Controller\PluginsController();
|
||||
}
|
||||
|
||||
\add_action('plugins_loaded', 'Foxstudio\Plugins\Template\initPlugin');
|
||||
3
plugins/pandaGadzety/readmy.md
Normal file
3
plugins/pandaGadzety/readmy.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Uwaga
|
||||
|
||||
Pamiętaj o umieszczeniu shortcode na stronie z koszykiem i zamówieniem
|
||||
88
plugins/pandaGadzety/repository/get_product_info.php
Normal file
88
plugins/pandaGadzety/repository/get_product_info.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace Foxstudio\Plugins\Template\Repository;
|
||||
|
||||
class ProductRepository {
|
||||
public string $serverUrl;
|
||||
|
||||
public function __construct($serverUrl) {
|
||||
$this->serverUrl = $serverUrl;
|
||||
}
|
||||
|
||||
public function getProductInfo($sku) {
|
||||
$args = [
|
||||
'headers' => [
|
||||
'content-type' => 'application/json',
|
||||
'api_key' => API_KEY
|
||||
],
|
||||
'body' => [
|
||||
"sku" => $sku
|
||||
]
|
||||
];
|
||||
$results = wp_remote_get($this->serverUrl . "/api/get_product_details", $args);
|
||||
$results = json_decode($results['body'], true);
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function getDeliveryInfo($sku) {
|
||||
$args = [
|
||||
'headers' => [
|
||||
'content-type' => 'application/json',
|
||||
'api_key' => API_KEY
|
||||
],
|
||||
'body' => [
|
||||
"sku" => $sku
|
||||
]
|
||||
];
|
||||
$results = wp_remote_get($this->serverUrl . "/api/get_product_details", $args);
|
||||
|
||||
$results = json_decode($results['body'], true);
|
||||
return $results['message']['inventory'];
|
||||
}
|
||||
|
||||
public function getLabelingInfo($sku) {
|
||||
$args = [
|
||||
'headers' => [
|
||||
'content-type' => 'application/json',
|
||||
'api_key' => API_KEY
|
||||
],
|
||||
'body' => [
|
||||
"sku" => $sku
|
||||
]
|
||||
];
|
||||
$results = wp_remote_get($this->serverUrl . "/api/get_product_details", $args);
|
||||
$results = json_decode($results['body'], true);
|
||||
return $results['message']['labeling'];
|
||||
}
|
||||
|
||||
public function getLowestPrice($price) {
|
||||
$args = [
|
||||
'headers' => [
|
||||
'content-type' => 'application/json',
|
||||
'api_key' => API_KEY
|
||||
],
|
||||
'body' => [
|
||||
"price" => $price
|
||||
]
|
||||
];
|
||||
$results = wp_remote_get($this->serverUrl . "/api/getLowestPrice", $args);
|
||||
$results = json_decode($results['body'], true);
|
||||
return $results['message']['lowestPrice'];
|
||||
}
|
||||
|
||||
public function getProductDescription($sku) {
|
||||
$args = [
|
||||
'headers' => [
|
||||
'content-type' => 'application/json',
|
||||
'api_key' => API_KEY
|
||||
],
|
||||
'body' => [
|
||||
"sku" => $sku
|
||||
]
|
||||
];
|
||||
$results = wp_remote_get($this->serverUrl . "/api/get_product_description", $args);
|
||||
$results = json_decode($results['body'], true);
|
||||
return $results['message'];
|
||||
}
|
||||
|
||||
}
|
||||
1
plugins/pandaGadzety/uninstall.php
Normal file
1
plugins/pandaGadzety/uninstall.php
Normal file
@ -0,0 +1 @@
|
||||
<?php
|
||||
0
plugins/pandaGadzety/utils/create-database.php
Normal file
0
plugins/pandaGadzety/utils/create-database.php
Normal file
104
plugins/pandaGadzety/utils/delivery-tab.php
Normal file
104
plugins/pandaGadzety/utils/delivery-tab.php
Normal file
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
namespace Foxstudio\Plugins\Template\Utils;
|
||||
use Foxstudio\Plugins\Template\Repository as Repository;
|
||||
class DeliveryTab {
|
||||
public function __construct()
|
||||
{
|
||||
add_filter('woocommerce_product_tabs', [$this, 'addCustomTab']);
|
||||
}
|
||||
|
||||
function addCustomTab($tabs)
|
||||
{
|
||||
|
||||
// Adds the new tab
|
||||
|
||||
$tabs['delivery_tab'] = array(
|
||||
'title' => __('Informacja o dostępności', 'pandaGadzety'),
|
||||
'priority' => 50,
|
||||
'callback' => [$this, 'customTabData']
|
||||
);
|
||||
|
||||
return $tabs;
|
||||
|
||||
}
|
||||
|
||||
function customTabData()
|
||||
{
|
||||
global $product;
|
||||
$sku = $product->get_sku();
|
||||
|
||||
\wp_enqueue_style("deliveryStyle", plugins_url("/pandaGadzety/assets/css/delivery.css"));
|
||||
|
||||
$product_repository = new Repository\ProductRepository(SERVER_URL);
|
||||
$results = $product_repository->getDeliveryInfo($sku);
|
||||
|
||||
$new_tab = [];
|
||||
foreach ($results as $data) {
|
||||
if($data['type'] == "central_stock") {
|
||||
$new_tab[$data['sku']]["central_stock"] = [
|
||||
"amount" => $data['amount'],
|
||||
"arrival_date" => $data['arrival_date']
|
||||
];
|
||||
}
|
||||
if($data['type'] == "external_stock") {
|
||||
$new_tab[$data['sku']]["external_stock"] = [
|
||||
"amount" => $data['amount'],
|
||||
"arrival_date" => $data['arrival_date']
|
||||
];
|
||||
}
|
||||
if($data['type'] == "incoming_to_central_stock") {
|
||||
$new_tab[$data['sku']]["incoming_to_central_stock"] = [
|
||||
"amount" => $data['amount'],
|
||||
"arrival_date" => $data['arrival_date']
|
||||
];
|
||||
}
|
||||
if($data['type'] == "incoming_to_external_stock") {
|
||||
$new_tab[$data['sku']]["incoming_to_external_stock"] = [
|
||||
"amount" => $data['amount'],
|
||||
"arrival_date" => $data['arrival_date']
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$tab = "<div id='delivery-tab'>";
|
||||
$tab .= "<table>";
|
||||
$tab .= "<tr>";
|
||||
$tab .= "<td>SKU</td>";
|
||||
$tab .= "<td colspan='2'>Magazyn centralny</td>";
|
||||
$tab .= "<td colspan='2'>Magazyn zewnętrzny</td>";
|
||||
$tab .= "</tr>";
|
||||
$tab .= "<tr>";
|
||||
$tab .= "<td>SKU</td>";
|
||||
$tab .= "<td>Na magazynie</td>";
|
||||
$tab .= "<td>Nadchodząca dostawa na magazyn</td>";
|
||||
$tab .= "<td>Dostępne w ciągu 6-8 dni</td>";
|
||||
$tab .= "<td>Nadchodząca dostawa na magazyn</td>";
|
||||
$tab .= "</tr>";
|
||||
foreach ($new_tab as $key => $value) {
|
||||
$tab .= "<tr>";
|
||||
$tab .= "<td>" . $key . "</td>";
|
||||
$tab .= "<td>" . $value["central_stock"]['amount'] . " szt.</td>";
|
||||
$tab .= "<td>";
|
||||
$tab .= !empty($value["incoming_to_central_stock"]['amount']) ? $value["incoming_to_central_stock"]['amount'] . "szt.": "0 szt.";
|
||||
$tab .= "<span>". (!empty($value["incoming_to_central_stock"]['arrival_date']) ? $value["incoming_to_central_stock"]['arrival_date'] : "") ."</span>";
|
||||
$tab .= "</td>";
|
||||
$tab .= "<td>";
|
||||
$tab .= !empty($value["external_stock"]['amount']) ? $value["external_stock"]['amount'] . "szt.": "0 szt.";
|
||||
$tab .= "</td>";
|
||||
$tab .= "<td>";
|
||||
$tab .= !empty($value["incoming_to_external_stock"]['amount']) ? $value["incoming_to_external_stock"]['amount'] . "szt.": "0 szt.";
|
||||
$tab .= "<span>" . (!empty($value["incoming_to_external_stock"]['arrival_date']) ? $value["incoming_to_external_stock"]['arrival_date'] : "") . "</span>";
|
||||
$tab .= "</td>";
|
||||
$tab .= "</tr>";
|
||||
|
||||
}
|
||||
$tab .= "</table>";
|
||||
|
||||
$tab .= "</div>";
|
||||
|
||||
|
||||
echo $tab;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Foxstudio\Plugins\Template\Utils;
|
||||
class InformationAboutLabelingMixed {
|
||||
|
||||
public function __construct() {
|
||||
// \add_action('woocommerce_before_cart', [$this, 'add_description'], 10);
|
||||
\add_shortcode("InformationAboutLabelingMixed", [$this, 'add_description']);
|
||||
}
|
||||
|
||||
function add_description($arg)
|
||||
{
|
||||
$title = "Nie łączymy zamówień bez znakowania i ze znakowaniem!";
|
||||
return '<div id="info" style="border-width: 0 0 0 5px; border-style:solid; border-color: var(--primary); padding: 10px; margin-bottom: 20px; background-color: rgba(0, 180, 225, 0.1); font-weight: bold">' . $title . '</div>';
|
||||
|
||||
}
|
||||
}
|
||||
39
plugins/pandaGadzety/utils/information-about-realization.php
Normal file
39
plugins/pandaGadzety/utils/information-about-realization.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Foxstudio\Plugins\Template\Utils;
|
||||
class InformationAboutLabeling {
|
||||
|
||||
public function __construct() {
|
||||
// \add_filter('woocommerce_checkout_before_order_review', [$this, 'showInformationAboutLabeling'], 20);
|
||||
\add_shortcode("InformationAboutLabeling", [$this, 'showInformationAboutLabeling']);
|
||||
}
|
||||
|
||||
function showInformationAboutLabeling()
|
||||
{
|
||||
|
||||
$html = '<div id="info" style="border-width: 0 0 0 5px; border-style:solid; border-color: var(--primary); padding: 10px; margin-bottom: 20px; background-color: rgba(0, 180, 225, 0.1); font-weight: bold">';
|
||||
$html .= '
|
||||
|
||||
Do realizacji zamówienia Foxstudio przystąpi wówczas gdy:<br>
|
||||
<br>
|
||||
Klient prześle wiadomość e-mail, poprzez sklep internetowy lub osobiście przekaże pełne zamówienie ze wszystkimi wytycznymi, szczegółami zamówienia dotyczącymi danego produktu (m.in. wypisaną rozmiarówka, wybraną odzieżą wraz z krojami, kolorystyką, wielkością nadruków, umiejscowieniem nadruków) oraz poprawnie przygotowanymi plikami graficznych do znakowania (w przypadku znakowania sitodrukiem, termotransferem, haftem komputerowym, folią flex, flexem lateksowym niezbędne są pliki graficzne zapisane wektorowo),<br>
|
||||
<br>
|
||||
W przypadku znakowania Produktu Klient zaakceptuje sposób i ułożenie znakowania na Produkcie.<br>
|
||||
<br>
|
||||
Termin realizacji podany przy wcześniejszej wycenie będzie liczony od momentu spełnienia wszystkich przesłanek określonych w ppkt 3.1. Jeżeli termin realizacji nie został podany to przyjmuje się następujące ramy czasowe trwania w zależności od rodzaju produktu i znakowania:<br>
|
||||
a) Produkty nieznakowane do od 3 do 7 dni roboczych,<br>
|
||||
b) Produkty znakowane do od 7 do 14 dni roboczych.<br>
|
||||
Foxstudio zastrzega możliwość wydłużenia terminów realizacji w przypadku zaistnienia przyczyn niezależnych od Foxstudio.<br>
|
||||
<br>
|
||||
Potwierdzenie złożenia oraz przyjęcia do realizacji Zamówienia zostanie przesłane Klientowi przez Foxstudio w formie wiadomości e-mail z poziomu domeny foxstudio.eu lub Pandagadzety.pl.<br>
|
||||
<br>
|
||||
Przed złożeniem zamówienia Klient zobowiązany jest do zapoznania się z treścią niniejszego Regulaminu. Złożenie zamówienia w firmie Foxstudio oznacza, iż Klient rozumie i akceptuje wszystkie postanowienia Regulaminu
|
||||
|
||||
';
|
||||
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
|
||||
}
|
||||
}
|
||||
329
plugins/pandaGadzety/utils/labeling-description-tab.php
Normal file
329
plugins/pandaGadzety/utils/labeling-description-tab.php
Normal file
@ -0,0 +1,329 @@
|
||||
<?php
|
||||
namespace Foxstudio\Plugins\Template\Utils;
|
||||
|
||||
use Foxstudio\Plugins\Template\Repository as Repository;
|
||||
|
||||
class LabelingDescriptionTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
add_filter('woocommerce_product_tabs', [$this, 'addCustomTab']);
|
||||
}
|
||||
|
||||
function addCustomTab($tabs)
|
||||
{
|
||||
|
||||
// Adds the new tab
|
||||
|
||||
$tabs['labeling_description_tab'] = array(
|
||||
'title' => __('Opis znakowań', 'pandaGadzety'),
|
||||
'priority' => 50,
|
||||
'callback' => [$this, 'customTabData']
|
||||
);
|
||||
|
||||
return $tabs;
|
||||
|
||||
}
|
||||
|
||||
public function customTabData()
|
||||
{
|
||||
\wp_enqueue_style("descriptionStyle", plugins_url("/pandaGadzety/assets/css/labeling-description.css"));
|
||||
// https://andapresent.com/pl/pl/pages/printing
|
||||
echo "
|
||||
<div class='labeling-description-box'>
|
||||
<img src='https://andapresent.com/pl/images/0x0/auto/printing-2020-br_wqv0x88i.jpg?v=1' />
|
||||
<div>
|
||||
<h3>Haft</h3>
|
||||
<p>
|
||||
Haft jest używany do zdobienia wyrobów tekstylnych, dzięki czemu uzyskujemy trwałe i wysokiej jakości nadruki za pomocą automatycznej hafciarki, która nakłada nitkę przez ściegi igłowe. Dopasowanie Pantone nie jest możliwe, ze względu na ograniczone kolory nici.
|
||||
<br>
|
||||
<b>Kod:</b> BR
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class='labeling-description-box'>
|
||||
<img src='https://andapresent.com/pl/images/0x0/auto/printing-2020-c_xw9rz5yj.jpg?v=1' />
|
||||
<div>
|
||||
<h3>Nadruk ceramiczny</h3>
|
||||
<p>
|
||||
Druk ceramiczny służy do oznaczania kubków, szklanek i niektórych przedmiotów metalowych za pomocą specjalnych farb ceramicznych wypalanych w wysokiej temperaturze. Etykieta jest nakładana na produkt podobnie jak druk transferowy, a następnie wypalana w piecu.
|
||||
<br>
|
||||
<b>Kod:</b> C
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class='labeling-description-box'>
|
||||
<img src='https://andapresent.com/pl/images/0x0/auto/printing-2020-dg_xuvsxwib.jpg?v=1' />
|
||||
<div>
|
||||
<h3>Cyfrowa wkładka papierowa</h3>
|
||||
<p>
|
||||
Druk cyfrowy służy do nadrukowywania produktów papierowych i wkładów papierowych w jakości fotograficznej. Wkładki papierowe mogą być produkowane w różnych rozmiarach i kształtach.
|
||||
<br>
|
||||
<b>Kod:</b> DG
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class='labeling-description-box'>
|
||||
<img src='https://andapresent.com/pl/images/0x0/auto/printing-2020-do_hr0xkhqw.jpg?v=1' />
|
||||
<div>
|
||||
<h3>Epoxy</h3>
|
||||
<p>
|
||||
Epoxy doming jest unikalną technologią druku, z wykorzystaniem pełnokolorowych zadrukowanych naklejek pokrytych 2-składnikową żywicą. W rezultacie obrobiona naklejka będzie miała trójwymiarowy wygląd. Logo z powierzchnią epoksydową może być produkowane w niestandardowych kształtach i jest odporne na promienie UV.
|
||||
<br>
|
||||
<b>Kod:</b> DO
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class='labeling-description-box'>
|
||||
<img src='https://andapresent.com/pl/images/0x0/auto/printing-2020-dt_3a7340pm.jpg?v=1' />
|
||||
<div>
|
||||
<h3>Transfer cyfrowy</h3>
|
||||
<p>
|
||||
Transfer cyfrowy to nowoczesna, full kolorowa alternatywa dla tradycyjnego druku transferowego. Projekt jest drukowany w jakości fotograficznej na papierze transferowym za pomocą specjalnej drukarki cyfrowej, a następnie nakładany na produkt za pomocą prasy termicznej. Nasza technologia transferu cyfrowego nie ma ograniczeń co do wielkości ani kształtu nadruków.
|
||||
<br>
|
||||
<b>Kod:</b> DT
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class='labeling-description-box'>
|
||||
<img src='https://andapresent.com/pl/images/0x0/auto/print-tech-dtt_uy8w67q8.jpg?v=1' />
|
||||
<div>
|
||||
<h3>Transfer cyfrowy na tekstyliach</h3>
|
||||
<p>
|
||||
Transfer cyfrowy na tekstyliach to odmiana transferu cyfrowego zoptymalizowana pod kątem tworzenia trwałych i odpornych nadruków na odzieży i akcesoriach tekstylnych. Aby zmaksymalizować trwałość nadruku, pierz odzież w temperaturze poniżej 40 stopni Celsjusza.
|
||||
<br>
|
||||
<b>Kod:</b> DTT
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class='labeling-description-box'>
|
||||
<img src='https://andapresent.com/pl/images/0x0/auto/printing-2020-e_hq860ysg.jpg?v=1' />
|
||||
<div>
|
||||
<h3>Grawer</h3>
|
||||
<p>
|
||||
Grawerowanie wykorzystuje lasery do znakowania produktu. Powierzchnia praktycznie spala się podczas procesu tworzenia logo. Nawet małe logo można wydrukować dokładnie. Grawerowanie ma zastosowanie do metalu, drewna, szkła i niektórych produktów z tworzyw sztucznych.
|
||||
<br>
|
||||
<b>Kod:</b> E
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class='labeling-description-box'>
|
||||
<img src='https://andapresent.com/pl/images/0x0/auto/print-tech-er_xlfpsq1m.jpg?v=1' />
|
||||
<div>
|
||||
<h3>Grawer rotacyjny</h3>
|
||||
<p>
|
||||
Grawerowanie rotacyjne wykorzystuje laser do znakowania powierzchni produktów cylindrycznych. Za pomocą specjalnego urządzenia rotacyjnego grawerowany produkt jest obracany podczas procesu drukowania, co pozwala na pokrycie dużego nadruku. Grawerowanie rotacyjne ma zastosowanie do metalu, drewna, bambusa, szkła i niektórych wyrobów ceramicznych.
|
||||
<br>
|
||||
<b>Kod:</b> ER
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class='labeling-description-box'>
|
||||
<img src='https://andapresent.com/pl/images/0x0/auto/printing-2020-o_ferfbzab.jpg?v=1' />
|
||||
<div>
|
||||
<h3>Tłoczenie</h3>
|
||||
<p>
|
||||
Wytłaczanie to elegancki proces, który zmienia powierzchnię wytłoczonego materiału, tworząc wrażenie 3D. Wrażenie to uzyskuje się poprzez wciśnięcie specjalnie wykonanej matrycy na powierzchnię produktu.
|
||||
<br>
|
||||
<b>Kod:</b> O
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class='labeling-description-box'>
|
||||
<img src='https://andapresent.com/pl/images/0x0/auto/print-tech-op_2y624cho.jpg?v=1' />
|
||||
<div>
|
||||
<h3>Nadruk atramentowy</h3>
|
||||
<p>
|
||||
Nadruk atramentowy służy do zadrukowywania płaskich powierzchni w pełnym kolorze za pomocą specjalnej szybkiej drukarki atramentowej. Ponieważ nadruk atramentowy nie wykorzystuje białych atramentów, kolory nadruku mogą być efektem koloru bazowego produktu. Druk atramentowy ma zastosowanie na materiałach porowatych, takich jak papier, naturalny bambus i drewno.
|
||||
<br>
|
||||
<b>Kod:</b> OP
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class='labeling-description-box'>
|
||||
<img src='https://andapresent.com/pl/images/0x0/auto/printing-2020-p_1j6m9hyu.jpg?v=1' />
|
||||
<div>
|
||||
<h3>Tampodruk </h3>
|
||||
<p>
|
||||
Tampodruk to najpopularniejsza, tradycyjna metoda znakowania atramentem. Ta technologia wykorzystuje podkładkę silikonową do przenoszenia atramentu na przedmiot z drobnymi detalami i wysoką dokładnością, stosowaną do szerokiej gamy materiałów. Tampodruk umożliwia etykietowanie zakrzywionych powierzchni.
|
||||
<br>
|
||||
<b>Kod:</b> P
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class='labeling-description-box'>
|
||||
<img src='https://andapresent.com/pl/images/0x0/auto/printing-2020-re_v1f8cvoq.jpg?v=1' />
|
||||
<div>
|
||||
<h3>Kolorowy grawer</h3>
|
||||
<p>
|
||||
Kolorowy grawer to specjalna technologia, wykorzystująca promienie laserowe o różnych długościach fali, aby uzyskać kolorowe nadruki na przedmiotach metalowych, bez użycia barwników i chemikaliów.
|
||||
<br>
|
||||
<b>Kod:</b> RE
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class='labeling-description-box'>
|
||||
<img src='https://andapresent.com/pl/images/0x0/auto/printing-2020-rs_x2fk9g49.jpg?v=1' />
|
||||
<div>
|
||||
<h3>Cylindryczny sitodruk</h3>
|
||||
<p>
|
||||
Rotacyjny sitodruk to specjalny rodzaj sitodruku do etykietowania butelek. Rotacyjny maszyna sitodrukowa obraca produkt równolegle z sitem, co powoduje ciągłe drukowanie na całej powierzchni produktu.
|
||||
<br>
|
||||
<b>Kod:</b> RS
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class='labeling-description-box'>
|
||||
<img src='https://andapresent.com/pl/images/0x0/auto/print-tech-ruv_0dbq7l4d.jpg?v=1' />
|
||||
<div>
|
||||
<h3>Nadruk rotacyjny UV Led</h3>
|
||||
<p>
|
||||
Druk rotacyjny UV LED to cyfrowy, pełnokolorowy proces znakowania w celu tworzenia nadruków o jakości fotograficznej bezpośrednio na powierzchni przedmiotów cylindrycznych i stożkowych, co pozwala na pokrycie przedmiotu dużym nadrukiem. Rotacyjne nadruki UV LED są pokryte przezroczystym lakierem, co zapewnia wyjątkowy wygląd i dodatkową trwałość.
|
||||
<br>
|
||||
<b>Kod:</b> RUV
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class='labeling-description-box'>
|
||||
<img src='https://andapresent.com/pl/images/0x0/auto/printing-2020-s_kdmrwzd2.jpg?v=1' />
|
||||
<div>
|
||||
<h3>Sitodruk</h3>
|
||||
<p>
|
||||
Sitodruk jest tradycyjnym, opartym na farbach procesem zdobienia (dla produktów płaskich lub spłaszczanych) o wysokiej trwałości i dokładności kolorów. Podczas procesu sitodruku farba jest bezpośrednio rozprowadzana po powierzchni sita, a następnie utrwalana za pomocą obróbki cieplnej.
|
||||
<br>
|
||||
<b>Kod:</b> S
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class='labeling-description-box'>
|
||||
<img src='https://andapresent.com/pl/images/0x0/auto/printing-2020-su_k75axd6y.jpg?v=1' />
|
||||
<div>
|
||||
<h3>Sublimacja</h3>
|
||||
<p>
|
||||
Druk sublimacyjny to pełnokolorowa, cyfrowa technika zdobienia z fotograficzną jakością. Wzory drukowane są specjalnym tuszem na papierze transferowym, a następnie wprasowywane na gorąco w powierzchnię produktu. Sublimacja ma zastosowanie do produktów poliestrowych w jasnych kolorach lub powierzchniach przystosowanych pod sublimację.
|
||||
<br>
|
||||
<b>Kod:</b> SU
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class='labeling-description-box'>
|
||||
<img src='https://andapresent.com/pl/images/0x0/auto/printing-2020-t_wacvh4d0.jpg?v=1' />
|
||||
<div>
|
||||
<h3>Transfer</h3>
|
||||
<p>
|
||||
Druk transferowy opiera się na tradycyjnym sitodruku, jednak zamiast bezpośredniego drukowania na materiale, projekt jest drukowany na papierze transferowym, a następnie wgrzewany za pomocą prasy termicznej. Druk transferowy ma zastosowanie do szerokiej gamy produktów i ma kilka zalet w porównaniu z sitodrukiem.
|
||||
<br>
|
||||
<b>Kod:</b> T
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class='labeling-description-box'>
|
||||
<img src='https://andapresent.com/pl/images/0x0/auto/printing-2020-uv_6zisr3bc.jpg?v=1' />
|
||||
<div>
|
||||
<h3>Technologia UV LED</h3>
|
||||
<p>
|
||||
Druk UV LED jest pełnokolorowym, cyfrowym procesem zdobienia wykorzystującym utwardzane promieniowaniem UV atramenty. Loga są drukowane bezpośrednio na powierzchni produktu w wysokiej rozdzielczości, dając niemalże efekt fotograficzny.
|
||||
<br>
|
||||
<b>Kod:</b> UV
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class='labeling-description-box'>
|
||||
<img src='https://andapresent.com/pl/images/0x0/auto/printing-2020-vf_rh13sisc.jpg?v=1' />
|
||||
<div>
|
||||
<h3>Vision Film druk</h3>
|
||||
<p>
|
||||
Druk Vision Film jest specjalną techniką druku szkieł okularów przeciwsłonecznych. Podczas tego procesu nakłada się cyfrowo nadrukowaną i perforowaną folię, umożliwiając wysoki stopień personalizacji.
|
||||
<br>
|
||||
<b>Kod:</b> VF
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class='labeling-description-box'>
|
||||
<img src='https://andapresent.com/pl/images/0x0/auto/printing-2020-vs_bxxzea8x.jpg?v=1' />
|
||||
<div>
|
||||
<h3>Winylowa naklejka</h3>
|
||||
<p>
|
||||
Naklejki winylowe są cyfrowo drukowane w full kolorze. Są to naklejki samoprzylepne przeznaczone do różnych w tym trudnych do drukowania produktów. Mogą być produkowane w różnych rozmiarach i kształtach.
|
||||
<br>
|
||||
<b>Kod:</b> VS
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class='labeling-description-box'>
|
||||
<img src='https://andapresent.com/pl/images/0x0/auto/printing-2020-wpc_bpod2zyv.jpg?v=1' />
|
||||
<div>
|
||||
<h3>Transfer na białej ceramice</h3>
|
||||
<p>
|
||||
Specjalna technologia znakowania full kolor dla białych, ceramicznych produktów, w oparciu o technologie transferu.
|
||||
<br>
|
||||
<b>Kod:</b> WPC
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
";
|
||||
}
|
||||
|
||||
}
|
||||
63
plugins/pandaGadzety/utils/labeling-tab.php
Normal file
63
plugins/pandaGadzety/utils/labeling-tab.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
namespace Foxstudio\Plugins\Template\Utils;
|
||||
use Foxstudio\Plugins\Template\Repository as Repository;
|
||||
class LabelingTab {
|
||||
public function __construct()
|
||||
{
|
||||
add_filter('woocommerce_product_tabs', [$this, 'addCustomTab']);
|
||||
}
|
||||
|
||||
function addCustomTab($tabs)
|
||||
{
|
||||
|
||||
// Adds the new tab
|
||||
|
||||
$tabs['labeling_tab'] = array(
|
||||
'title' => __('Tabela znakowań', 'pandaGadzety'),
|
||||
'priority' => 50,
|
||||
'callback' => [$this, 'customTabData']
|
||||
);
|
||||
|
||||
return $tabs;
|
||||
|
||||
}
|
||||
|
||||
function customTabData()
|
||||
{
|
||||
global $product;
|
||||
\wp_enqueue_style("labelingStyle", plugins_url("/pandaGadzety/assets/css/labeling.css"));
|
||||
$sku = $product->get_sku();
|
||||
$product_repository = new Repository\ProductRepository(SERVER_URL);
|
||||
$results = $product_repository->getLabelingInfo($sku);
|
||||
// The new tab content
|
||||
|
||||
$html = "<div id='labeling'>";
|
||||
$html .= "<table>";
|
||||
foreach ($results as $data) {
|
||||
$html .= $this->get_labeling_block($data['image'], $data['technology'], $data['name']);
|
||||
}
|
||||
$html .= "</table>";
|
||||
$html .= "</div>";
|
||||
|
||||
echo $html;
|
||||
}
|
||||
|
||||
public function get_labeling_block($img, $technology, $position) {
|
||||
$html = "<tr>";
|
||||
$html .= "<td><img src='" . $img . "'/></td>";
|
||||
$html .= "<td>";
|
||||
$html .= "<b>Technologia: </b> ". $technology."<br>";
|
||||
$html .= "<b>Pozycja: </b> ". $position."";
|
||||
$html .= "</td>";
|
||||
$html .= "</tr>";
|
||||
// $html = "<div>";
|
||||
// $html .= "<div class='photo'><img src='" . $img . "'/></div>";
|
||||
// $html .= "<div class='data'>";
|
||||
// $html .= "<p><b>Technologia: </b> ". $technology."</p>";
|
||||
// $html .= "</div>";
|
||||
// $html .= "</div>";
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
}
|
||||
23
plugins/pandaGadzety/utils/load-file.php
Normal file
23
plugins/pandaGadzety/utils/load-file.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Foxstudio\Plugins\Template\Utils;
|
||||
|
||||
function mapAndIncludeFiles($folderPath)
|
||||
{
|
||||
$files = scandir($folderPath);
|
||||
foreach ($files as $file) {
|
||||
if ($file != '.' && $file != '..') {
|
||||
if (is_file($folderPath . $file)) {
|
||||
// Check if the file is a PHP file
|
||||
if (pathinfo($folderPath . $file, PATHINFO_EXTENSION) == 'php') {
|
||||
// Include the PHP file
|
||||
echo $folderPath . $file;
|
||||
include_once $folderPath . $file;
|
||||
}
|
||||
} elseif (is_dir($folderPath . $file)) {
|
||||
// Recursively call mapAndIncludeFiles for subdirectories
|
||||
mapAndIncludeFiles($folderPath . $file . '/');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
36
plugins/pandaGadzety/utils/logistic-minimum.php
Normal file
36
plugins/pandaGadzety/utils/logistic-minimum.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Foxstudio\Plugins\Template\Utils;
|
||||
|
||||
class LogisticMinimum {
|
||||
|
||||
private int $minimumOrderPrice, $fee;
|
||||
|
||||
public function __construct($minimumOrderPrice, $fee)
|
||||
{
|
||||
|
||||
$this->minimumOrderPrice = $minimumOrderPrice;
|
||||
$this->fee = $fee;
|
||||
\add_action('woocommerce_cart_calculate_fees', [$this, 'wc_add_surcharge']);
|
||||
|
||||
}
|
||||
|
||||
function wc_add_surcharge($cart)
|
||||
{
|
||||
$total_price = 0;
|
||||
|
||||
foreach ($cart->get_cart() as $cart_item) {
|
||||
if (isset($cart_item['custom_data']['technology'])) {
|
||||
$price = $cart_item['data']->get_price();
|
||||
$quantity = $cart_item['quantity'];
|
||||
|
||||
$total_price += $price * $quantity;
|
||||
}
|
||||
}
|
||||
|
||||
if ($total_price < $this->minimumOrderPrice && $total_price > 0):
|
||||
$cart->add_fee('Minimum logistyczne (dla zamówień poniżej 350 zł)', $this->fee);
|
||||
endif;
|
||||
|
||||
}
|
||||
}
|
||||
41
plugins/pandaGadzety/utils/modify-product-name.php
Normal file
41
plugins/pandaGadzety/utils/modify-product-name.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Foxstudio\Plugins\Template\Utils;
|
||||
|
||||
use \Foxstudio\Plugins\Template\Repository\ProductRepository;
|
||||
|
||||
class ShowMinimumPrice {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
\add_action('woocommerce_shop_loop_item_title', [$this, 'change_product_title']);
|
||||
\remove_action('woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10);
|
||||
|
||||
}
|
||||
|
||||
function change_product_title()
|
||||
{
|
||||
global $product;
|
||||
|
||||
if (!$product) {
|
||||
return;
|
||||
}
|
||||
|
||||
// $price = 85.56;
|
||||
$sku = $product->get_sku();
|
||||
$price = $product->get_price();
|
||||
$price = $this->getLowestPrice($price);
|
||||
echo '<h2 class="woocommerce-loop-product__title">' . get_the_title() . '</h2><p style="font-weight: 700;">od ' . $price . ' zł</p>';
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function getLowestPrice($price) {
|
||||
|
||||
$productRepository = new ProductRepository(SERVER_URL);
|
||||
$price = $productRepository->getLowestPrice($price);
|
||||
return $price;
|
||||
}
|
||||
|
||||
}
|
||||
38
plugins/pandaGadzety/utils/notice.php
Normal file
38
plugins/pandaGadzety/utils/notice.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Foxstudio\Plugins\Template\Utils;
|
||||
|
||||
class Notice
|
||||
{
|
||||
|
||||
public function noticeSuccess($title)
|
||||
{
|
||||
return $this->displayNotice('success', $title);
|
||||
}
|
||||
|
||||
public function noticeWarning($title)
|
||||
{
|
||||
return $this->displayNotice('warning', $title);
|
||||
}
|
||||
|
||||
public function noticeError($title)
|
||||
{
|
||||
return $this->displayNotice('error', $title);
|
||||
}
|
||||
|
||||
public function noticeInfo($title)
|
||||
{
|
||||
return $this->displayNotice('info', $title);
|
||||
}
|
||||
|
||||
private function displayNotice($type, $title)
|
||||
{
|
||||
return wc_print_notice($title, $type);
|
||||
// return '
|
||||
// <div class="notice notice-'. esc_attr($type) .' is-dismissible">
|
||||
// <p>'. esc_html($title) .'</p>
|
||||
// </div>
|
||||
// ';
|
||||
}
|
||||
|
||||
}
|
||||
374
plugins/pandaGadzety/utils/product-calculator.php
Normal file
374
plugins/pandaGadzety/utils/product-calculator.php
Normal file
@ -0,0 +1,374 @@
|
||||
<?php
|
||||
namespace Foxstudio\Plugins\Template\Utils;
|
||||
|
||||
use Foxstudio\Plugins\Template\Repository as Repository;
|
||||
use Exception;
|
||||
|
||||
class PriceCalculator
|
||||
{
|
||||
private Repository\ProductRepository $productRepository;
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->productRepository = new Repository\ProductRepository(SERVER_URL);
|
||||
|
||||
|
||||
|
||||
add_action('woocommerce_init', [$this, 'ensureWooSession']);
|
||||
|
||||
|
||||
add_action('wp_enqueue_scripts', [$this, 'loadArchiveImages']);
|
||||
|
||||
|
||||
// Calculator
|
||||
add_filter('woocommerce_single_product_summary', [$this, 'calculatorView']);
|
||||
|
||||
add_action('template_redirect', [$this, 'addToCart']);
|
||||
add_action('woocommerce_before_single_product', [$this, 'addToCart']);
|
||||
|
||||
add_action('woocommerce_before_calculate_totals', [$this, 'updatePrice'], 10);
|
||||
|
||||
// Show custom data
|
||||
add_filter('woocommerce_get_item_data', [$this, 'showCustomData'], 10, 3);
|
||||
add_action('woocommerce_checkout_create_order_line_item', [$this, 'wdm_add_custom_order_line_item_meta'], 10, 4);
|
||||
|
||||
// Remove default add to cart
|
||||
remove_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
|
||||
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
|
||||
|
||||
// Add custom styles
|
||||
\wp_enqueue_style('hidden-add-to-cart', "/wp-content/plugins/pandaGadzety/assets/css/hidden-add-to-cart.css");
|
||||
|
||||
}
|
||||
|
||||
function wdm_add_custom_order_line_item_meta($item, $cart_item_key, $values, $order)
|
||||
{
|
||||
if (array_key_exists('custom_data', $values)) {
|
||||
|
||||
if(!empty($values['custom_data']['option'])) {
|
||||
$item->add_meta_data('option', $values['custom_data']['option']);
|
||||
}
|
||||
|
||||
if(!empty($values['custom_data']['technology'])) {
|
||||
$item->add_meta_data('Technologia', $values['custom_data']['technology']);
|
||||
}
|
||||
|
||||
if(!empty($values['custom_data']['labeling_price'])) {
|
||||
$item->add_meta_data('Cena znakowania', $values['custom_data']['labeling_price']);
|
||||
}
|
||||
|
||||
if(!empty($values['custom_data']['setup_price'])) {
|
||||
$item->add_meta_data('Cena przygotowania', $values['custom_data']['setup_price']);
|
||||
}
|
||||
|
||||
if(!empty($values['custom_data']['product_price'])) {
|
||||
$item->add_meta_data('Cena produktu', $values['custom_data']['product_price']);
|
||||
}
|
||||
if(!empty($values['custom_data']['colors'])) {
|
||||
$item->add_meta_data('Ilość kolorów', $values['custom_data']['colors']);
|
||||
}
|
||||
|
||||
if(!empty($values['custom_data']['photo'])) {
|
||||
$item->add_meta_data('Zdjęcie nadruku', \wp_get_attachment_image($values['custom_data']['photo'], array(800, 600)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function ensureWooSession() {
|
||||
if (!wc()->session->has_session()) {
|
||||
wc()->session->set_customer_session_cookie(true);
|
||||
}
|
||||
}
|
||||
|
||||
public function loadArchiveImages() {
|
||||
|
||||
$skus = [];
|
||||
|
||||
global $wp_query;
|
||||
foreach ( $wp_query->posts as $post ) {
|
||||
$p = wc_get_product( $post->ID );
|
||||
if ( $p && $p->get_sku() ) {
|
||||
$skus[] = $p->get_sku();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ( WC()->cart ) {
|
||||
foreach ( WC()->cart->get_cart() as $cart_item ) {
|
||||
$p = $cart_item['data'];
|
||||
if ( $p && $p->get_sku() ) {
|
||||
$skus[] = $p->get_sku();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$skus = array_unique( $skus );
|
||||
|
||||
|
||||
$productData = [];
|
||||
foreach ( $skus as $sku ) {
|
||||
try {
|
||||
$info = $this->productRepository->getProductInfo( $sku );
|
||||
if ( ! empty( $info['message'] ) ) {
|
||||
$productData[ $sku ] = [
|
||||
'img' => $info['message']['productBaseInfo']['primary_img'] ?? null,
|
||||
];
|
||||
}
|
||||
} catch ( \Throwable $th ) {}
|
||||
}
|
||||
|
||||
|
||||
wp_enqueue_script(
|
||||
'archive-images-js',
|
||||
plugins_url( '/pandaGadzety/assets/js/archive-images.js' ),
|
||||
[ 'wc-cart-fragments' ],
|
||||
null,
|
||||
true
|
||||
);
|
||||
wp_localize_script( 'archive-images-js', 'archiveImagesData', [
|
||||
'products' => $productData,
|
||||
] );
|
||||
}
|
||||
|
||||
public function addToCart() {
|
||||
global $post;
|
||||
|
||||
if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
|
||||
// $item_data['custom_data']['new_price'] = 99;
|
||||
// $item_data['custom_data']['color'] = 'red';
|
||||
// $item_data['custom_data']['uuid'] = uniqid();
|
||||
|
||||
$product = wc_get_product($post->ID);
|
||||
|
||||
if (!$product) {
|
||||
wc_add_notice('Nie znaleziono produktu', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
$itemData = [];
|
||||
|
||||
if(!empty($_POST['option'])) {
|
||||
$itemData['custom_data']['option'] = $_POST['option'];
|
||||
}
|
||||
|
||||
if(!empty($_POST['technology'])) {
|
||||
$itemData['custom_data']['technology'] = $_POST['technology'];
|
||||
}
|
||||
|
||||
if(!empty($_POST['quantity'])) {
|
||||
$itemData['custom_data']['quantity'] = $_POST['quantity'];
|
||||
}
|
||||
|
||||
if(!empty($_POST['labeling_price'])) {
|
||||
$itemData['custom_data']['labeling_price'] = $_POST['labeling_price'];
|
||||
} else {
|
||||
$itemData['custom_data']['labeling_price'] = 0;
|
||||
}
|
||||
|
||||
if(!empty($_POST['setup_price'])) {
|
||||
$itemData['custom_data']['setup_price'] = $_POST['setup_price'];
|
||||
} else {
|
||||
$itemData['custom_data']['setup_price'] = 0;
|
||||
}
|
||||
|
||||
if(!empty($_POST['colors'])) {
|
||||
$itemData['custom_data']['colors'] = $_POST['colors'];
|
||||
} else {
|
||||
$itemData['custom_data']['colors'] = 0;
|
||||
}
|
||||
|
||||
if(!empty($_FILES['photo'])) {
|
||||
$itemData['custom_data']['photo'] = $this->uploadFile('photo', $product->get_id());
|
||||
} else {
|
||||
$itemData['custom_data']['photo'] = null;
|
||||
}
|
||||
|
||||
|
||||
$itemData['custom_data']['product_price'] = $_POST['product_price'];
|
||||
|
||||
$itemData['custom_data']['total_price'] = floatval($_POST['product_price']) + floatval($_POST['labeling_price']);
|
||||
|
||||
$attributes = [];
|
||||
if(!empty($_POST['attributes'])) {
|
||||
foreach ($_POST['attributes'] as $key => $value) {
|
||||
$attributes['attribute_' . $key] = $value;
|
||||
wc_add_notice('Błąd podczas dodawania do koszyka', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
$cart_item_key = WC()->cart->add_to_cart(
|
||||
$product->get_id(),
|
||||
$_POST['quantity'],
|
||||
0,
|
||||
$attributes,
|
||||
$itemData
|
||||
);
|
||||
|
||||
if ($cart_item_key) {
|
||||
wp_redirect(wc_get_cart_url());
|
||||
exit;
|
||||
} else {
|
||||
wc_add_notice('Błąd podczas dodawania do koszyka', 'error');
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
wc_add_notice('Wystąpił błąd: ' . $th->getMessage(), 'error');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function updatePrice($cart) {
|
||||
if (is_admin() && !defined('DOING_AJAX'))
|
||||
return;
|
||||
|
||||
if (did_action('woocommerce_before_calculate_totals') >= 2)
|
||||
return;
|
||||
|
||||
foreach ($cart->get_cart() as $cart_item) {
|
||||
if (isset($cart_item['custom_data']['total_price'])) {
|
||||
$setup_price = !empty($cart_item['custom_data']['setup_price']) ? $cart_item['custom_data']['setup_price']: 0;
|
||||
$price = $setup_price / $cart_item['quantity'] + $cart_item['custom_data']['total_price'];
|
||||
// TODO: calculate data after price update;
|
||||
$cart_item['data']->set_price($price);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function showCustomData($item_data, $custom_data)
|
||||
{
|
||||
// var_dump($custom_data);
|
||||
if(!empty($custom_data['custom_data']['option'])) {
|
||||
$item_data[] = [
|
||||
'key' => "Pozycja znakowania",
|
||||
'value' => wc_clean($custom_data['custom_data']['option']),
|
||||
];
|
||||
}
|
||||
if(!empty($custom_data['custom_data']['technology'])) {
|
||||
$item_data[] = [
|
||||
'key' => "Technologia znakowania",
|
||||
'value' => wc_clean($custom_data['custom_data']['technology']),
|
||||
];
|
||||
}
|
||||
// if(!empty($custom_data['custom_data']['quantity'])) {
|
||||
// $item_data[] = [
|
||||
// 'key' => "Ilość",
|
||||
// 'value' => wc_clean($custom_data['custom_data']['quantity']),
|
||||
// ];
|
||||
// }
|
||||
if(!empty($custom_data['custom_data']['labeling_price'])) {
|
||||
$item_data[] = [
|
||||
'key' => "Cena znakowania",
|
||||
'value' => wc_clean($custom_data['custom_data']['labeling_price']),
|
||||
];
|
||||
}
|
||||
if(!empty($custom_data['custom_data']['setup_price'])) {
|
||||
$item_data[] = [
|
||||
'key' => "Koszt przygotowania",
|
||||
'value' => wc_clean($custom_data['custom_data']['setup_price']),
|
||||
];
|
||||
}
|
||||
|
||||
/*if(!empty($custom_data['custom_data']['product_price'])) {
|
||||
$item_data[] = [
|
||||
'key' => "Cena produktu",
|
||||
'value' => wc_clean($custom_data['custom_data']['product_price']),
|
||||
];
|
||||
}*/
|
||||
|
||||
if(!empty($custom_data['custom_data']['photo'])) {
|
||||
$attachment_id = $custom_data['custom_data']['photo'];
|
||||
|
||||
if (is_numeric($attachment_id)) {
|
||||
$image_html = wp_get_attachment_image($attachment_id, array(800, 600));
|
||||
$item_data[] = [
|
||||
'key' => "Zdjęcie nadruku",
|
||||
'value' => $image_html,
|
||||
];
|
||||
} else {
|
||||
$item_data[] = [
|
||||
'key' => "Zdjęcie nadruku",
|
||||
'value' => 'Brak przesłanego pliku',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($custom_data['custom_data']['color'])) {
|
||||
$item_data[] = [
|
||||
'key' => "Kolor",
|
||||
'value' => wc_clean($custom_data['custom_data']['color']),
|
||||
];
|
||||
}
|
||||
|
||||
if(!empty($custom_data['custom_data']['colors'])) {
|
||||
$item_data[] = [
|
||||
'key' => "Ilość kolorów",
|
||||
'value' => wc_clean($custom_data['custom_data']['colors']),
|
||||
];
|
||||
}
|
||||
// if(!empty($custom_data['custom_data']['total_price'])) {
|
||||
// $item_data[] = [
|
||||
// 'key' => "Suma",
|
||||
// 'value' => wc_clean($custom_data['custom_data']['total_price']),
|
||||
// ];
|
||||
// }
|
||||
|
||||
return $item_data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function calculatorView()
|
||||
{
|
||||
global $product;
|
||||
|
||||
$productInfo = $this->productRepository->getProductInfo($product->get_sku());
|
||||
if(!empty($productInfo)) {
|
||||
$productInfo = $productInfo['message'];
|
||||
|
||||
\wp_enqueue_script("calculatorScript", plugins_url("/pandaGadzety/assets/js/calculator.js"));
|
||||
wp_localize_script('calculatorScript', 'calculatorScriptVariables', array(
|
||||
'productInfo' => $productInfo
|
||||
)
|
||||
);
|
||||
|
||||
\wp_enqueue_style("calculatorStyle", plugins_url("/pandaGadzety/assets/css/calculator.css"));
|
||||
|
||||
$html = file_get_contents("wp-content/plugins/pandaGadzety/view/calculator.html");
|
||||
echo $html;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*private function uploadFile($key, $id) {
|
||||
// TODO: verify format
|
||||
require_once (ABSPATH . 'wp-admin/includes/image.php');
|
||||
require_once (ABSPATH . 'wp-admin/includes/file.php');
|
||||
require_once (ABSPATH . 'wp-admin/includes/media.php');
|
||||
return \media_handle_upload($key, $id);
|
||||
}*/
|
||||
|
||||
|
||||
private function uploadFile($key, $id) {
|
||||
require_once (ABSPATH . 'wp-admin/includes/image.php');
|
||||
require_once (ABSPATH . 'wp-admin/includes/file.php');
|
||||
require_once (ABSPATH . 'wp-admin/includes/media.php');
|
||||
|
||||
$attachment_id = media_handle_upload($key, $id);
|
||||
|
||||
if (is_wp_error($attachment_id)) {
|
||||
// error_log('Błąd przesyłania pliku: ' . $attachment_id->get_error_message());
|
||||
|
||||
//wc_add_notice('Błąd przesyłania pliku: ' . $attachment_id->get_error_message(), 'error');
|
||||
return null;
|
||||
}
|
||||
|
||||
return $attachment_id;
|
||||
}
|
||||
|
||||
}
|
||||
44
plugins/pandaGadzety/utils/product-description-tab.php
Normal file
44
plugins/pandaGadzety/utils/product-description-tab.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
namespace Foxstudio\Plugins\Template\Utils;
|
||||
use Foxstudio\Plugins\Template\Repository as Repository;
|
||||
class ProductDescriptionTab {
|
||||
public function __construct()
|
||||
{
|
||||
add_filter('woocommerce_product_description_heading', '__return_null');
|
||||
add_filter('woocommerce_product_tabs', [$this, 'addCustomTab']);
|
||||
}
|
||||
|
||||
function addCustomTab($tabs)
|
||||
{
|
||||
|
||||
// Adds the new tab
|
||||
|
||||
$tabs['product_description_tab'] = array(
|
||||
'title' => __('O produkcie', 'pandaGadzety'),
|
||||
'priority' => 50,
|
||||
'callback' => [$this, 'customTabData']
|
||||
);
|
||||
|
||||
return $tabs;
|
||||
|
||||
}
|
||||
|
||||
public function customTabData()
|
||||
{
|
||||
global $product;
|
||||
\wp_enqueue_style("descriptionStyle", plugins_url("/pandaGadzety/assets/css/description.css"));
|
||||
$sku = $product->get_sku();
|
||||
$product_repository = new Repository\ProductRepository(SERVER_URL);
|
||||
$results = $product_repository->getProductDescription($sku);
|
||||
|
||||
echo "<div id='description-tab'>";
|
||||
echo $results['short_description'];
|
||||
echo "<table><tr><th colspan='2'>Informacje o produkcie</th></tr>";
|
||||
foreach ($results['specification'] as $key => $value) {
|
||||
echo "<tr><td>".$value['name']."</td><td>".$value['value']."</td></tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
}
|
||||
88
plugins/pandaGadzety/view/calculator.html
Normal file
88
plugins/pandaGadzety/view/calculator.html
Normal file
@ -0,0 +1,88 @@
|
||||
<div class="calculator">
|
||||
<div class="toggle">
|
||||
<div class="header single-product__calculator-header">
|
||||
<div class="title">
|
||||
<h3>Personalizacja produktu</h3>
|
||||
</div>
|
||||
<div class="product-name__title">
|
||||
Nazwa produktu
|
||||
</div>
|
||||
<div id="product-name">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
|
||||
<form method="post" data-gtm-form-interact-id="0" enctype="multipart/form-data">
|
||||
<div class="options single-product__calculator-header">
|
||||
<label>
|
||||
<p>Pozycja znakowania</p>
|
||||
<div id="options"></div>
|
||||
</label>
|
||||
<label>
|
||||
<div id="technology"></div>
|
||||
</label>
|
||||
<div id="color_number"></div>
|
||||
<div id="attributes"></div>
|
||||
<div id="attributes-photo"></div>
|
||||
<div class="labeling_image">
|
||||
<div id="select_image"></div>
|
||||
</div>
|
||||
<div id="stock"></div>
|
||||
</div>
|
||||
<div class="hr"></div>
|
||||
|
||||
<div class="price-wrapper">
|
||||
<div class="price">
|
||||
<label>
|
||||
<p>Ilość do zamówienia</p>
|
||||
<input type="number" value="50" min="50" name="quantity" id="quantity">
|
||||
</label>
|
||||
<label>
|
||||
<p>Grafika na nadruk</p>
|
||||
<input type="file" name="photo" id="photo">
|
||||
</label>
|
||||
<span>
|
||||
Do wykonania wizualizacji należy przesłać <strong>plik wektorowy</strong> w wybranej kolorystyce. Plik z takim logo może mieć rozszerzenie: cdr, eps lub ai (ewentualnie krzywe w pdf).
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="labeling_summary">
|
||||
<p>Podsumowanie</p>
|
||||
<table>
|
||||
<tr>
|
||||
<td id="dimensions_name"></td>
|
||||
<td id="dimensions"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Cena nadruku:</td>
|
||||
<td><span id="price">0.00</span> zł / szt.</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Cena przygotowania:</td>
|
||||
<td><span id="setup_price">0</span> zł</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Cena produktu:</td>
|
||||
<td><span id="product_price">0.00</span> zł / szt.</span></td>
|
||||
</tr>
|
||||
<tr class="suma">
|
||||
<td><b>Suma:</b></td>
|
||||
<td><span id="total_price">0.00</span> zł / szt.</span></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<div class="add-to-cart">
|
||||
<input type="hidden" name="labeling_price" />
|
||||
<input type="hidden" name="setup_price" />
|
||||
<input type="hidden" name="product_price" />
|
||||
<input type="hidden" name="total_price" />
|
||||
<input type="submit" id="add_to_cart_button" value="Dodaj do koszyka">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Loading…
Reference in New Issue
Block a user