Skip to content

Instantly share code, notes, and snippets.

@lukecav
lukecav / functions.php
Created September 8, 2017 14:19
Remove add to cart button from shop and product page in WooCommerce
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
@lukecav
lukecav / functions.php
Last active October 31, 2017 18:48
Hide prices on the shop & category page in WooCommerce and remove add to cart but replace with a view product button
// First, remove Add to Cart Button
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
// Second, add View Product Button
add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_view_product_button', 10);
function woocommerce_view_product_button() {
global $product;
// Add new Redonda customizer panel
// Used to hook into the Customizer Manager so the section can be easily enabled/disabled as needed
add_filter( 'wpex_customizer_panels', function( $panels ) {
$panels['redonda'] = array(
'title' => __( 'Redonda', 'total' ),
'is_section' => true,
);
return $panels;
} );
// Change button on all external product links
add_filter( 'woocommerce_loop_add_to_cart_link', function( $html, $product ) {
if ( 'external' === $product->get_type() ) {
$html = '<a href="' . esc_url( get_permalink() ) . '/#inquire" class="button">Inquire</a>';
}
return $html;
}, 10, 2 );
// Add custom inquire button to all external product pages
@kreamweb
kreamweb / functions.php
Created August 22, 2017 07:52
Change From email and From name in the email Send request a quote, with the email and name of customer.
<?php
add_filter('ywraq_request_a_quote_send_email_from_address','ywraq_request_a_quote_send_email_from_address', 10, 2);
function ywraq_request_a_quote_send_email_from_address( $email, $object ){
$email = $object->raq['user_email'];
return $email;
}
add_filter('ywraq_request_a_quote_send_email_from_name','ywraq_request_a_quote_send_email_from_name', 10, 2);
@lukecav
lukecav / Page Rules
Last active May 31, 2024 15:57
CloudFlare page rules for WooCommerce pages
domain.com/my-account*
domain.com/cart*
domain.com/checkout*
Disable Apps
Disable Peformance
Bypass Cache
@mariovalney
mariovalney / woo-enable-reviews-bulk-edit.php
Created August 7, 2017 19:55
WooCommerce Enable Reviews - Bulk Edit
<?php
/**
*
* Plugin Name: WooCommerce Enable Reviews - Bulk Edit
* Description: Allow enable reviews by bulk edit into WooCommerce
* Version: 1.0.0
* Author: Mário Valney
* Author URI: http://mariovalney.com
* Text Domain: woo-enable-reviews-bulk-edit
*
@rynaldos-zz
rynaldos-zz / wc-dcc-php
Last active July 2, 2020 05:22
[WooCommerce 3.0+] Change the default state and country on the checkout
add_filter( 'default_checkout_billing_country', 'change_default_checkout_country' );
add_filter( 'default_checkout_billing_state', 'change_default_checkout_state' );
function change_default_checkout_country() {
return 'XX'; // country code
}
function change_default_checkout_state() {
return 'XX'; // state code
}
/**
* Adds a prefix to the existing WooCommerce order number.
*
* @param int $order_id the order ID
* @param \WC_Order $order the order object
* @return string the updated order number
*/
function sv_wc_add_order_number_prefix( $order_id, $order ) {
return "SV-{$order_id}";
@rynaldos-zz
rynaldos-zz / wc-cc-single-pages.php
Last active July 2, 2020 05:20
[WooCommerce 3.0] Show currency converter on single product pages
add_filter( 'woocommerce_get_price_html', 'wc_ninja_add_sc_price_display', 20 );
function wc_ninja_add_sc_price_display( $price ) {
if ( is_product() ) {
echo do_shortcode( '[woocommerce_currency_converter] ' );
}
return $price;
}
//Did this help? Donate me some BTC: 1BEsm8VMkYhSFJ92cvUYwxCtsfsB2rBfiG