From e70aa1f554854fd531242e3ceb3fb68e9e399ec5 Mon Sep 17 00:00:00 2001 From: Dwindi Ramadhana Date: Thu, 12 Mar 2026 19:10:56 +0700 Subject: [PATCH] fix: resolve email shortcode rendering and TypeScript errors - Fix EmailRenderer.php: add missing \ namespace prefix on instanceof checks for WC_Order, WC_Product, WC_Customer in get_variables() (root cause of unrendered {order_number} etc. in all order emails) - Fix ProductCard.tsx: remove deprecated isClassic/isModern/isBoutique branches, consolidate into single settings-driven render path - Fix AccountLayout.tsx: add missing return statement - Remove orphaned Layout.tsx (imported nothing, referenced missing Header) --- customer-spa/src/components/Layout/Layout.tsx | 19 - customer-spa/src/components/ProductCard.tsx | 389 ++++-------------- .../Account/components/AccountLayout.tsx | 6 +- includes/Core/Notifications/EmailRenderer.php | 6 +- 4 files changed, 76 insertions(+), 344 deletions(-) delete mode 100644 customer-spa/src/components/Layout/Layout.tsx diff --git a/customer-spa/src/components/Layout/Layout.tsx b/customer-spa/src/components/Layout/Layout.tsx deleted file mode 100644 index 9b84723..0000000 --- a/customer-spa/src/components/Layout/Layout.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import React from 'react'; -import Header from './Header'; -import Footer from './Footer'; - -interface LayoutProps { - children: React.ReactNode; -} - -export default function Layout({ children }: LayoutProps) { - return ( -
-
-
- {children} -
-
-
- ); -} diff --git a/customer-spa/src/components/ProductCard.tsx b/customer-spa/src/components/ProductCard.tsx index 25f9356..6dffbc8 100644 --- a/customer-spa/src/components/ProductCard.tsx +++ b/customer-spa/src/components/ProductCard.tsx @@ -80,15 +80,14 @@ export function ProductCard({ product, onAddToCart }: ProductCardProps) { // Determine button variant and position based on settings const buttonVariant = addToCart.style === 'outline' ? 'outline' : addToCart.style === 'text' ? 'ghost' : 'default'; const showButtonOnHover = addToCart.position === 'overlay'; - const buttonPosition = addToCart.position; // 'below', 'overlay', 'bottom' const isTextOnly = addToCart.style === 'text'; // Card style variations - adapt to column count - const cardStyle = layout.card_style || 'card'; const gridCols = parseInt(layout.grid_columns) || 3; // More columns = cleaner styling const getCardClasses = () => { + const cardStyle = layout.card_style || 'card'; if (cardStyle === 'minimal') { return gridCols >= 4 ? 'overflow-hidden hover:opacity-90 transition-opacity' @@ -114,330 +113,37 @@ export function ProductCard({ product, onAddToCart }: ProductCardProps) { 'right': 'text-right', }[layout.card_text_align || 'left'] || 'text-left'; - // Classic Layout - Traditional card with border - if (isClassic) { - return ( - -
- {/* Image */} -
- {product.image ? ( - {product.name} - ) : ( -
- No Image -
- )} - - {/* Sale Badge */} - {elements.sale_badges && product.on_sale && discount && ( -
- {discount} -
- )} - - {/* Wishlist Button */} - {showWishlist && ( -
- -
- )} - - {/* Hover/Overlay Button */} - {showButtonOnHover && ( -
- -
- )} -
- - {/* Content */} -
-

- {product.name} -

- - {/* Price */} -
- {product.on_sale && product.regular_price ? ( - <> - - {formatPrice(product.sale_price || product.price)} - - - {formatPrice(product.regular_price)} - - - ) : ( - - {formatPrice(product.price)} - - )} -
- - {/* Add to Cart Button - Below Image */} - {!showButtonOnHover && ( - - )} -
-
- - ); - } - - // Modern Layout - Minimalist, clean - if (isModern) { - return ( - -
- {/* Image */} -
- {product.image ? ( - {product.name} - ) : ( -
- No Image -
- )} - - {/* Sale Badge */} - {elements.sale_badges && product.on_sale && discount && ( -
- {discount} -
- )} - - {/* Wishlist Button */} - {showWishlist && ( -
- -
- )} - - {/* Hover Overlay - Only show if position is hover/overlay */} - {showButtonOnHover && ( -
- -
- )} -
- - {/* Content */} -
-

- {product.name} -

- - {/* Price */} -
- {product.on_sale && product.regular_price ? ( - <> - - {formatPrice(product.sale_price || product.price)} - - - {formatPrice(product.regular_price)} - - - ) : ( - - {formatPrice(product.price)} - - )} -
- - {/* Add to Cart Button - Below or Bottom */} - {!showButtonOnHover && ( -
- {buttonPosition === 'below' && ( - - )} - - {buttonPosition === 'bottom' && ( - - )} -
- )} -
-
- - ); - } - - // Boutique Layout - Luxury, elegant - if (isBoutique) { - return ( - -
- {/* Image */} -
- {product.image ? ( - {product.name} - ) : ( -
- No Image -
- )} - - {/* Sale Badge */} - {elements.sale_badges && product.on_sale && discount && ( -
- {discount} -
- )} - - {/* Wishlist Button */} - {showWishlist && ( -
- -
- )} -
- - {/* Content */} -
-

- {product.name} -

- - {/* Price */} -
- {product.on_sale && product.regular_price ? ( - <> - - {formatPrice(product.sale_price || product.price)} - - - {formatPrice(product.regular_price)} - - - ) : ( - - {formatPrice(product.price)} - - )} -
- - {/* Add to Cart Button */} - -
-
- - ); - } - - // Launch Layout - Funnel optimized (shouldn't show product grid, but just in case) + // Unified card render — adapts via card_style (card / minimal / overlay) + shop settings return ( - -
-
+ +
+ {/* Image */} +
{product.image ? ( {product.name} ) : ( -
+
No Image
)} + {/* Sale Badge */} + {elements.sale_badges && product.on_sale && discount && ( +
+ {discount} +
+ )} + {/* Wishlist Button */} {showWishlist && ( -
+
)} + + {/* Hover/Overlay Button */} + {showButtonOnHover && ( +
+ +
+ )}
-
-

{product.name}

-
- {formatPrice(product.price)} + {/* Content */} +
+

+ {product.name} +

+ + {/* Price */} +
+ {product.on_sale && product.regular_price ? ( + <> + + {formatPrice(product.sale_price || product.price)} + + + {formatPrice(product.regular_price)} + + + ) : ( + + {formatPrice(product.price)} + + )}
- + + {/* Add to Cart Button */} + {!showButtonOnHover && ( + + )}
diff --git a/customer-spa/src/pages/Account/components/AccountLayout.tsx b/customer-spa/src/pages/Account/components/AccountLayout.tsx index 4611a99..093abdd 100644 --- a/customer-spa/src/pages/Account/components/AccountLayout.tsx +++ b/customer-spa/src/pages/Account/components/AccountLayout.tsx @@ -201,7 +201,8 @@ export function AccountLayout({ children }: AccountLayoutProps) { ); // Responsive layout: Tabs on mobile, Sidebar on desktop -
+ return ( +
{/* Mobile: Tab Navigation */} {renderTabNav()} @@ -216,6 +217,7 @@ export function AccountLayout({ children }: AccountLayoutProps) {
-
+
+ ); } diff --git a/includes/Core/Notifications/EmailRenderer.php b/includes/Core/Notifications/EmailRenderer.php index 8e5a32f..e84e3d8 100644 --- a/includes/Core/Notifications/EmailRenderer.php +++ b/includes/Core/Notifications/EmailRenderer.php @@ -195,7 +195,7 @@ class EmailRenderer ]; // Order variables - if ($data instanceof WC_Order) { + if ($data instanceof \WC_Order) { // Calculate estimated delivery (3-5 business days from now) $estimated_delivery = date('F j', strtotime('+3 days')) . '-' . date('j', strtotime('+5 days')); @@ -289,7 +289,7 @@ class EmailRenderer } // Product variables - if ($data instanceof WC_Product) { + if ($data instanceof \WC_Product) { $variables = array_merge($variables, [ 'product_id' => $data->get_id(), 'product_name' => $data->get_name(), @@ -302,7 +302,7 @@ class EmailRenderer } // Customer variables - if ($data instanceof WC_Customer) { + if ($data instanceof \WC_Customer) { // Get temp password from user meta (stored during auto-registration) $user_temp_password = get_user_meta($data->get_id(), '_woonoow_temp_password', true);