Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

william commerce testing #4099

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<!doctype html>
<html dir="ltr" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
<title>Cart</title>

<script type="module" src="/build/atomic.esm.js"></script>
<script nomodule src="/build/atomic.js"></script>
<link rel="stylesheet" href="/themes/coveo.css" />
<script type="module">
import {commerceEngine} from './engine.mjs';

(async () => {
await customElements.whenDefined('atomic-commerce-interface');
const commerceInterface = document.querySelector('atomic-commerce-recommendation-interface');
await commerceInterface.initializeWithEngine(commerceEngine);
})();
</script>
<style>
atomic-commerce-recommendation-list {
margin-top: var(--atomic-layout-spacing-y);
--atomic-recs-number-of-columns: 3;
}

@media only screen and (max-width: 1024px) {
atomic-commerce-recommendation-list {
--atomic-recs-number-of-columns: 1;
}
}
</style>
</head>
<body>
<h1>Cart</h1>
<main>
<section>
<atomic-commerce-recommendation-interface>
<atomic-commerce-layout>
<atomic-layout-section section="main">
<atomic-commerce-recommendation-list
id="cart_recommendations"
slot-id="52870f54-4edc-4767-b8b5-f126ff2de9bf"
products-per-page="3"
>
<atomic-product-template>
<template>
<atomic-product-section-name>
<atomic-product-link class="font-bold"></atomic-product-link>
</atomic-product-section-name>
<atomic-product-section-visual>
<atomic-product-image field="ec_images"></atomic-product-image>
</atomic-product-section-visual>
<atomic-product-section-metadata>
<atomic-product-text field="ec_brand" class="block text-neutral-dark"></atomic-product-text>
<atomic-product-rating field="ec_rating"></atomic-product-rating>
</atomic-product-section-metadata>
<atomic-product-section-emphasized>
<atomic-product-price currency="USD"></atomic-product-price>
</atomic-product-section-emphasized>
<atomic-product-section-children>
<atomic-product-children></atomic-product-children>
</atomic-product-section-children>
</template>
</atomic-product-template>
</atomic-commerce-recommendation-list>
</atomic-layout-section>
</atomic-commerce-layout>
</atomic-commerce-recommendation-interface>
</section>
</main>
<script src="../../header.js" type="text/javascript"></script>
<script src="commerce-nav.mjs" type="module"></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
const barcaRoot = 'https://sports-dev.barca.group';
export const navContent = {
Homepage: {href: 'homepage.html', label: 'Homepage', barcaUrl: barcaRoot},
Sonars: {
href: 'listing-sonars.html',
label: 'Sonars',
barcaUrl: `https://engineering.barca.group/barca-spa/Sonars/c/19500`,
},
Cart: {href: 'cart.html', label: 'Cart', barcaUrl: `${barcaRoot}/cart`},
Search: {
href: 'search.html',
label: 'Search',
barcaUrl: `${barcaRoot}/commerce-search`,
},
};

export const getParamValue = (param) => {
return document.location.hash
.substring(1)
.split('&')
.reduce(function (res, item) {
var parts = item.split('=');
res[parts[0]] = parts[1];
return res;
}, {})[param];
};

const makeLinks = () => {
return Object.values(navContent)
.map(
(nav) =>
`<a href="${nav.href}" style="margin-right: 10px; color: var(--atomic-neutral-dark); text-decoration: none;">${nav.label}</a>`
)
.join('');
};

const nav = document.createElement('nav');
nav.style.borderTop = '1px solid var(--atomic-neutral-dark)';
nav.style.marginBottom = '2em';

nav.innerHTML = `
<p style="margin-bottom: 0; margin-left: 0;">Commerce website nav menu:</p>
<ul style="display: inline-block; font-size: var(--atomic-text-lg); padding-left: 0;">
${makeLinks()}
</ul>
`;

document.body.querySelector('header').insertAdjacentElement('beforeend', nav);

const isOnSearchPage = () => {
return (
window.location.pathname ===
'/examples/commerce-website-engineering/search.html'
);
};

if (!isOnSearchPage()) {
const standaloneSearchBoxHTML = `
<atomic-layout-section section="search">
<atomic-commerce-search-box redirection-url="./search.html">
<atomic-commerce-search-box-recent-queries></atomic-commerce-search-box-recent-queries>
<atomic-commerce-search-box-query-suggestions></atomic-commerce-search-box-query-suggestions>
<atomic-commerce-search-box-instant-products image-size="small">
<atomic-product-template>
<template>
<atomic-product-section-name>
<atomic-product-link class="font-bold"></atomic-product-link>
</atomic-product-section-name>
<atomic-product-section-visual>
<atomic-product-image field="ec_images"></atomic-product-image>
</atomic-product-section-visual>
<atomic-product-section-metadata>
<atomic-product-text field="ec_brand" class="block text-neutral-dark"></atomic-product-text>
<atomic-product-rating field="ec_rating"></atomic-product-rating>
</atomic-product-section-metadata>
<atomic-product-section-emphasized>
<atomic-product-price currency="USD"></atomic-product-price>
</atomic-product-section-emphasized>
<atomic-product-section-children>
<atomic-product-children></atomic-product-children>
</atomic-product-section-children>
</template>
</atomic-product-template>
</atomic-commerce-search-box-instant-products>
</atomic-commerce-search-box>
</atomic-layout-section>
`;

const standaloneSearchBox = document.createElement('search');

const atomicCommerceInterface = document.body.querySelector(
'atomic-commerce-interface'
);

if (atomicCommerceInterface) {
standaloneSearchBox.innerHTML = standaloneSearchBoxHTML;
const atomicCommerceLayout = atomicCommerceInterface.querySelector(
'atomic-commerce-layout'
);
if (atomicCommerceLayout) {
atomicCommerceLayout.insertAdjacentHTML(
'afterbegin',
standaloneSearchBoxHTML
);
} else {
atomicCommerceInterface.insertAdjacentElement(
'afterbegin',
standaloneSearchBox
);
}
} else {
standaloneSearchBox.innerHTML = `
<atomic-commerce-interface type="search">
${standaloneSearchBoxHTML}
</atomic-commerce-interface>`;

document.body
.querySelector('main')
.insertAdjacentElement('afterbegin', standaloneSearchBox);

const script = document.createElement('script');
script.type = 'module';
script.src = './init-standalone-search-box.js';
document.body.insertAdjacentElement('beforeend', script);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {navContent} from './commerce-nav.mjs';
import {buildCommerceEngine} from '/build/headless/commerce/headless.esm.js';

export const commerceEngine = buildCommerceEngine({
configuration: {
accessToken: 'xxc481d5de-16cb-4290-bd78-45345319d94c',
context: {
country: 'US',
currency: 'USD',
language: 'en',
view: {
url: navContent[document.title].barcaUrl,
referrer: document.referrer,
},
},
organizationId: 'barcasportsmcy01fvu',
environment: 'dev',
analytics: {
trackingId: 'engineering',
},
cart: {
items: [
{
productId: 'BE03621',
sku: 'BE03621_03647',
quantity: 1,
name: 'GarminMCB',
price: 600,
},
],
},
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<!doctype html>
<html dir="ltr" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
<title>Homepage</title>

<script type="module" src="/build/atomic.esm.js"></script>
<script nomodule src="/build/atomic.js"></script>
<link rel="stylesheet" href="/themes/coveo.css" />
<script type="module">
import {commerceEngine} from './engine.mjs';

(async () => {
await customElements.whenDefined('atomic-commerce-interface');
const commerceInterface = document.querySelector('atomic-commerce-recommendation-interface');

await commerceInterface.initializeWithEngine(commerceEngine);
})();
</script>
<style>
atomic-commerce-recommendation-list {
margin-top: var(--atomic-layout-spacing-y);
--atomic-recs-number-of-columns: 3;
}

@media only screen and (max-width: 1024px) {
atomic-commerce-recommendation-list {
--atomic-recs-number-of-columns: 1;
}
}
</style>
</head>
<body>
<h1>HOMEPAGE</h1>
<main>
<section>
<atomic-commerce-recommendation-interface>
<atomic-commerce-layout>
<atomic-layout-section section="main">
<atomic-commerce-recommendation-list
id="popular_bought"
slot-id="3216339b-f776-4cb1-8a21-018c8ec0f08c"
products-per-page="3"
>
<atomic-product-template>
<template>
<atomic-product-section-name>
<atomic-product-link class="font-bold"></atomic-product-link>
</atomic-product-section-name>
<atomic-product-section-visual>
<atomic-product-image field="ec_images"></atomic-product-image>
</atomic-product-section-visual>
<atomic-product-section-metadata>
<atomic-product-field-condition if-defined="ec_brand">
<atomic-product-text field="ec_brand" class="block text-neutral-dark"></atomic-product-text>
</atomic-product-field-condition>
<atomic-product-field-condition if-defined="ec_brand">
<atomic-product-rating field="ec_rating"></atomic-product-rating>
</atomic-product-field-condition>
</atomic-product-section-metadata>
<atomic-product-section-emphasized>
<atomic-product-price currency="USD"></atomic-product-price>
</atomic-product-section-emphasized>
<atomic-product-section-children>
<atomic-product-children></atomic-product-children>
</atomic-product-section-children>
</template>
</atomic-product-template>
</atomic-commerce-recommendation-list>
<atomic-commerce-recommendation-list
id="popular_viewed"
slot-id="36ed24b6-d7e0-4c32-8815-c456cc1928e7"
products-per-page="3"
>
<atomic-product-template>
<template>
<atomic-product-section-name>
<atomic-product-link class="font-bold"></atomic-product-link>
</atomic-product-section-name>
<atomic-product-section-visual>
<atomic-product-image field="ec_images"></atomic-product-image>
</atomic-product-section-visual>
<atomic-product-section-metadata>
<atomic-product-field-condition if-defined="ec_brand">
<atomic-product-text field="ec_brand" class="block text-neutral-dark"></atomic-product-text>
</atomic-product-field-condition>
<atomic-product-field-condition if-defined="ec_brand">
<atomic-product-rating field="ec_rating"></atomic-product-rating>
</atomic-product-field-condition>
</atomic-product-section-metadata>
<atomic-product-section-emphasized>
<atomic-product-price currency="USD"></atomic-product-price>
</atomic-product-section-emphasized>
<atomic-product-section-children>
<atomic-product-children></atomic-product-children>
</atomic-product-section-children>
</template>
</atomic-product-template>
</atomic-commerce-recommendation-list>
</atomic-layout-section>
</atomic-commerce-layout>
</atomic-commerce-recommendation-interface>
</section>
</main>

<script src="../../header.js" type="text/javascript"></script>
<script src="commerce-nav.mjs" type="module"></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {commerceEngine} from './engine.mjs';

(async () => {
await customElements.whenDefined('atomic-commerce-interface');
const searchBox = document.querySelector('atomic-commerce-interface');
await searchBox.initializeWithEngine(commerceEngine);
})();
Loading
Loading