Skip to content

Commit

Permalink
always add ctb attributes if they exist. remove unused legacy ctb ren…
Browse files Browse the repository at this point in the history
…der method.

This effectively retires the supportsCTB const, these attributes are safe to include and only functional if a ctb module is included too
  • Loading branch information
circlecube committed Dec 13, 2023
1 parent 88c7aa5 commit 16c122f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 44 deletions.
1 change: 0 additions & 1 deletion components/marketplace/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { default as MarketplaceIsLoading } from '../marketplaceIsLoading/';
const defaults = {
eventendpoint: '/newfold-data/v1/events/',
perPage: 12,
supportsCTB: true,
appendCategoryToTitle: true,
text: {
title: 'Marketplace',
Expand Down
44 changes: 1 addition & 43 deletions components/marketplaceItem/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,53 +122,11 @@ const MarketplaceItem = ( { item, methods, constants } ) => {
};
}, [] );

const renderCTAs = ( item ) => {
let primaryCTA, secondaryCTA;
if ( item.primaryUrl && item.primaryCallToAction ) {
primaryCTA = (
<Button
variant="primary"
className="primary-cta"
target="_blank"
href={ item.primaryUrl }
// create CTB button attributes
{ ...( constants.supportsCTB && item.clickToBuyId
? {
'data-action': 'load-nfd-ctb',
'data-ctb-id': item.clickToBuyId,
}
: {} ) }
>
{ item.primaryCallToAction }
</Button>
);
}

if ( item.secondaryCallToAction && item.secondaryUrl ) {
secondaryCTA = (
<Button
variant="secondary"
className="secondary-cta"
target="_blank"
href={ item.secondaryUrl }
>
{ item.secondaryCallToAction }
</Button>
);
}
return (
<>
{ primaryCTA }
{ secondaryCTA }
</>
);
};

const renderPrimaryCTA = ( item ) => {
let primaryCTA = '';

if ( item.primaryCallToAction && item.primaryUrl ) {
if ( constants.supportsCTB && item.clickToBuyId ) {
if ( item.clickToBuyId ) {
primaryCTA = (
<Button
as="a"
Expand Down

0 comments on commit 16c122f

Please sign in to comment.