feat: temp password in emails + WC page redirects to SPA

1. Temp password for auto-registered users:
   - Store password in _woonoow_temp_password user meta (CheckoutController)
   - Add {user_temp_password} and {login_url} variables (EmailRenderer)
   - Update new_customer email template to show credentials

2. WC page redirects to SPA routes:
   - Added redirect_wc_pages_to_spa() in TemplateOverride
   - Maps: /shop → /store/#/, /cart → /store/#/cart, etc.
   - /checkout → /store/#/checkout, /my-account → /store/#/account
   - Single products → /store/#/products/{slug}

3. Removed shortcode system:
   - Commented out Shortcodes::init() in Bootstrap
   - WC pages now redirect to SPA instead
This commit is contained in:
Dwindi Ramadhana
2026-01-01 16:45:24 +07:00
parent 38a7a4ee23
commit 58681e272e
5 changed files with 78 additions and 19 deletions

View File

@@ -13,6 +13,9 @@ class TemplateOverride
*/
public static function init()
{
// Redirect WooCommerce pages to SPA routes early (before template loads)
add_action('template_redirect', [__CLASS__, 'redirect_wc_pages_to_spa'], 5);
// Hook to wp_loaded with priority 10 (BEFORE WooCommerce's priority 20)
// This ensures we process add-to-cart before WooCommerce does
add_action('wp_loaded', [__CLASS__, 'intercept_add_to_cart'], 10);
@@ -93,6 +96,59 @@ class TemplateOverride
}, 1);
}
/**
* Redirect WooCommerce pages to SPA routes
* Maps: /shop → /store/#/, /cart → /store/#/cart, etc.
*/
public static function redirect_wc_pages_to_spa()
{
// Get SPA page URL
$appearance_settings = get_option('woonoow_appearance_settings', []);
$spa_page_id = $appearance_settings['general']['spa_page'] ?? 0;
if (!$spa_page_id) {
return; // No SPA page configured
}
// Already on SPA page, don't redirect
global $post;
if ($post && $post->ID == $spa_page_id) {
return;
}
$spa_url = trailingslashit(get_permalink($spa_page_id));
// Check which WC page we're on and redirect
if (is_shop()) {
wp_redirect($spa_url . '#/', 302);
exit;
}
if (is_product()) {
global $product;
if ($product) {
$slug = $product->get_slug();
wp_redirect($spa_url . '#/products/' . $slug, 302);
exit;
}
}
if (is_cart()) {
wp_redirect($spa_url . '#/cart', 302);
exit;
}
if (is_checkout() && !is_order_received_page()) {
wp_redirect($spa_url . '#/checkout', 302);
exit;
}
if (is_account_page()) {
wp_redirect($spa_url . '#/account', 302);
exit;
}
}
/**
* Disable canonical redirects for SPA routes
* This prevents WordPress from redirecting /product/slug URLs