Skip to content

Commit

Permalink
Using global var for marketplace.
Browse files Browse the repository at this point in the history
  • Loading branch information
andfinally committed Feb 22, 2024
1 parent c146357 commit 23768c1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import Notice from '../notice/notice';

declare global {
interface Window {
wc: {
marketplace?: {
promotions: Promotion[];
};
wcMarketplace: {
promotions?: Promotion[];
};
}
}
Expand Down Expand Up @@ -41,7 +39,7 @@ const Promotions: () => null | JSX.Element = () => {
if ( currentPage !== 'wc-admin' ) {
return null;
}
const promotions = window.wc?.marketplace?.promotions ?? [];
const promotions = window.wcMarketplace?.promotions ?? [];
const currentDateUTC = Date.now();
const currentPath = decodeURIComponent( urlParams.get( 'path' ) || '' );
const currentTab = urlParams.get( 'tab' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ public function admin_scripts() {

wp_add_inline_script(
'wc-admin-app',
'(window.wc = window.wc || {}).marketplace = ' . wp_json_encode( array( 'promotions' => $promotions ) ),
'window.wcMarketplace = ' . wp_json_encode( array( 'promotions' => $promotions ) ),
'before'
);
}
Expand Down

0 comments on commit 23768c1

Please sign in to comment.