Skip to content

Commit

Permalink
Merge pull request #10 from imagewize/woocommerce-exists-check
Browse files Browse the repository at this point in the history
WooCommerce Existence Check
  • Loading branch information
jasperf authored Feb 2, 2025
2 parents 4020412 + 473964e commit 897e5a2
Showing 1 changed file with 49 additions and 44 deletions.
93 changes: 49 additions & 44 deletions site/web/app/themes/nynaeve/app/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,49 +134,54 @@
/**
* WooCommerce Support
*/
if (class_exists('WooCommerce')) {
add_theme_support('wc-product-gallery-zoom');
add_theme_support('wc-product-gallery-lightbox');
add_theme_support('wc-product-gallery-slider');

add_theme_support('wc-product-gallery-zoom');
add_theme_support('wc-product-gallery-lightbox');
add_theme_support('wc-product-gallery-slider');

/**
* WooCommerce Customizations
*
* Removes default WooCommerce price displays and add-to-cart functionality
* since this site operates on a quote-based system rather than direct sales.
*
* 1. Removes price display from single product pages and archive pages
* 2. Removes add-to-cart buttons from single product pages and archive pages
* 3. Adds a "Request Quote" button to single product pages only
* 4. Redirects users away from cart/checkout pages since they're not needed
*/

// Remove price and add to cart functionality from all product displays
add_action('init', function() {
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_price', 10);
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
remove_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10);
remove_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10);
});
/**
* WooCommerce Customizations
*
* Removes default WooCommerce price displays and add-to-cart functionality
* since this site operates on a quote-based system rather than direct sales.
*
* 1. Removes price display from single product pages and archive pages
* 2. Removes add-to-cart buttons from single product pages and archive pages
* 3. Adds a "Request Quote" button to single product pages only
* 4. Redirects users away from cart/checkout pages since they're not needed
*/

// Add "Request Quote" button to single product pages only
add_action('woocommerce_single_product_summary', function() {
?>
<div class="quote-button-wrapper mt68">
<a href="/contact-us"
class="text-center w-full px-4 py-3 bg-indigo-600 flex items-center
justify-center font-semibold text-lg text-white shadow-sm transition-all
duration-500 hover:bg-indigo-700 hover:shadow-indigo-400;">
Request Quote
</a>
</div>
<?php
}, 30);

// Redirect users from cart and checkout pages since they're not needed
add_action('template_redirect', function() {
if (is_cart() || is_checkout() || is_account_page()) {
wp_redirect(home_url());
exit;
}
});
// Remove price and add to cart functionality from all product displays
add_action('init', function() {
if (function_exists('remove_action')) {
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_price', 10);
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
remove_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10);
remove_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10);
}
});

// Add "Request Quote" button to single product pages only
add_action('woocommerce_single_product_summary', function() {
?>
<div class="quote-button-wrapper mt68">
<a href="/contact-us"
class="text-center w-full px-4 py-3 bg-indigo-600 flex items-center
justify-center font-semibold text-lg text-white shadow-sm transition-all
duration-500 hover:bg-indigo-700 hover:shadow-indigo-400;">
Request Quote
</a>
</div>
<?php
}, 30);

// Redirect users from cart and checkout pages since they're not needed
add_action('template_redirect', function() {
if (function_exists('is_cart') && function_exists('is_checkout') && function_exists('is_account_page')) {
if (is_cart() || is_checkout() || is_account_page()) {
wp_redirect(home_url());
exit;
}
}
});
}

0 comments on commit 897e5a2

Please sign in to comment.