Compare commits
No commits in common. "f69d990349e4d0a6fef637c08703a2ce6a683ca0" and "4489e705b8b1044cee941a0cfce627eb6b8d3eda" have entirely different histories.
f69d990349
...
4489e705b8
8 changed files with 20 additions and 48 deletions
|
|
@ -10,8 +10,7 @@
|
|||
"Bash(grep:*)",
|
||||
"Bash(npm run build:*)",
|
||||
"Bash(php test-shopify.php:*)",
|
||||
"WebFetch(domain:getkirby.com)",
|
||||
"WebFetch(domain:forum.getkirby.com)"
|
||||
"WebFetch(domain:getkirby.com)"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,10 +76,6 @@
|
|||
&:hover {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
svg {
|
||||
stroke: #000;
|
||||
}
|
||||
}
|
||||
|
||||
&__content {
|
||||
|
|
|
|||
|
|
@ -83,7 +83,6 @@
|
|||
}
|
||||
|
||||
.header-cart-btn {
|
||||
font-family: var(--font);
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
|
|
@ -110,11 +109,11 @@
|
|||
}
|
||||
|
||||
&:not(:empty)::before {
|
||||
content: "(";
|
||||
content: '(';
|
||||
}
|
||||
|
||||
&:not(:empty)::after {
|
||||
content: ")";
|
||||
content: ')';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -559,7 +559,6 @@ main {
|
|||
color: var(--color-txt);
|
||||
}
|
||||
#site-header .header-cart-btn {
|
||||
font-family: var(--font);
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
|
|
@ -1432,9 +1431,6 @@ body.is-fullscreen {
|
|||
.cart-drawer__close:hover {
|
||||
opacity: 0.7;
|
||||
}
|
||||
.cart-drawer__close svg {
|
||||
stroke: #000;
|
||||
}
|
||||
.cart-drawer__content {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -10,13 +10,6 @@
|
|||
return;
|
||||
}
|
||||
|
||||
const buttonTextDiv = addToCartBtn.querySelector('.txt[data-button-text]');
|
||||
|
||||
if (!buttonTextDiv) {
|
||||
console.error('Button text div not found');
|
||||
return;
|
||||
}
|
||||
|
||||
const texts = {
|
||||
add: addToCartBtn.dataset.textAdd || 'Add to cart',
|
||||
adding: addToCartBtn.dataset.textAdding || 'Adding...',
|
||||
|
|
@ -35,13 +28,13 @@
|
|||
}
|
||||
|
||||
addToCartBtn.disabled = true;
|
||||
const originalText = buttonTextDiv.textContent;
|
||||
buttonTextDiv.textContent = texts.adding;
|
||||
const originalText = addToCartBtn.textContent;
|
||||
addToCartBtn.textContent = texts.adding;
|
||||
|
||||
try {
|
||||
const cartResult = await cart.addToCart(variantId, 1);
|
||||
|
||||
buttonTextDiv.textContent = texts.added;
|
||||
addToCartBtn.textContent = texts.added;
|
||||
addToCartBtn.classList.add('success');
|
||||
|
||||
document.dispatchEvent(new CustomEvent('cart:updated', {
|
||||
|
|
@ -50,19 +43,19 @@
|
|||
|
||||
setTimeout(() => {
|
||||
addToCartBtn.disabled = false;
|
||||
buttonTextDiv.textContent = originalText;
|
||||
addToCartBtn.textContent = originalText;
|
||||
addToCartBtn.classList.remove('success');
|
||||
}, 1500);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error adding to cart:', error);
|
||||
|
||||
buttonTextDiv.textContent = texts.error;
|
||||
addToCartBtn.textContent = texts.error;
|
||||
addToCartBtn.classList.add('error');
|
||||
|
||||
setTimeout(() => {
|
||||
addToCartBtn.disabled = false;
|
||||
buttonTextDiv.textContent = originalText;
|
||||
addToCartBtn.textContent = originalText;
|
||||
addToCartBtn.classList.remove('error');
|
||||
}, 2000);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,10 +14,11 @@ return [
|
|||
],
|
||||
|
||||
'routes' => [
|
||||
// French products (default)
|
||||
// French product pages (default)
|
||||
[
|
||||
'pattern' => '(:any)',
|
||||
'action' => function($slug) {
|
||||
// Skip known pages
|
||||
if (in_array($slug, ['home', 'error', 'thanks'])) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -26,28 +27,28 @@ return [
|
|||
|
||||
foreach ($products as $product) {
|
||||
if ($product['handle'] === $slug) {
|
||||
$page = Page::factory([
|
||||
return Page::factory([
|
||||
'slug' => $product['handle'],
|
||||
'template' => 'product',
|
||||
'parent' => site()->homePage(),
|
||||
'content' => [
|
||||
'title' => $product['title'],
|
||||
'shopifyHandle' => $product['handle'],
|
||||
'uuid' => $product['id']
|
||||
]
|
||||
]);
|
||||
|
||||
site()->visit($page, 'fr');
|
||||
return $page;
|
||||
}
|
||||
}
|
||||
|
||||
// Not a product, let Kirby handle normally
|
||||
return null;
|
||||
}
|
||||
],
|
||||
// English products
|
||||
// English product pages
|
||||
[
|
||||
'pattern' => 'en/(:any)',
|
||||
'action' => function($slug) {
|
||||
// Skip known pages
|
||||
if (in_array($slug, ['home', 'error', 'thanks'])) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -56,21 +57,20 @@ return [
|
|||
|
||||
foreach ($products as $product) {
|
||||
if ($product['handle'] === $slug) {
|
||||
$page = Page::factory([
|
||||
return Page::factory([
|
||||
'slug' => $product['handle'],
|
||||
'template' => 'product',
|
||||
'parent' => site()->homePage(),
|
||||
'content' => [
|
||||
'title' => $product['title'],
|
||||
'shopifyHandle' => $product['handle'],
|
||||
'uuid' => $product['id']
|
||||
]
|
||||
]);
|
||||
|
||||
site()->visit($page, 'en');
|
||||
return $page;
|
||||
}
|
||||
}
|
||||
|
||||
// Not a product, let Kirby handle normally
|
||||
return null;
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
return function ($page, $kirby) {
|
||||
$shopifyHandle = $page->shopifyHandle()->or($page->slug())->value();
|
||||
$language = $kirby->language()->code();
|
||||
|
||||
return [
|
||||
'shopifyHandle' => $shopifyHandle,
|
||||
'language' => $language
|
||||
];
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue