Skip to content

Instantly share code, notes, and snippets.

<?php
if(!function_exists('wc_get_products')) {
return;
}
$paged = (get_query_var('paged')) ? absint(get_query_var('paged')) : 1;
$ordering = WC()->query->get_catalog_ordering_args();
$ordering['orderby'] = array_shift(explode(' ', $ordering['orderby']));
$ordering['orderby'] = stristr($ordering['orderby'], 'price') ? 'meta_value_num' : $ordering['orderby'];
@maddisondesigns
maddisondesigns / functions.php
Last active March 8, 2025 09:18
WooCommerce Custom Fields for Simple & Variable Products
/*
* Add our Custom Fields to simple products
*/
function mytheme_woo_add_custom_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
// Text Field
@gagimilicevic
gagimilicevic / extend_cf7_with_new_feature.php
Created March 27, 2018 15:03
Extending CF7 with new feature or option from backend
<?php
function cf7_active_campaign_add_meta_boxes() {
add_meta_box( 'cf7-active-campaign-settings', 'Active Campaign', 'cf7_active_campaign_metaboxes', '', 'form', 'low');
}
add_action( 'wpcf7_add_meta_boxes', 'cf7_active_campaign_add_meta_boxes' );
function cf7_activecampaign_add_page_panels($panels) {
$panels['redirect-panel'] = array( 'title' => 'Active Campaign Settings', 'callback' => 'cf7_activecampaign_page_panel_meta' );
return $panels;
}
@hiranthi
hiranthi / woo-checkout.php
Last active August 26, 2021 00:52
WooCommerce checkout steps
<?php
/**
* Display the checkout steps so the customer knows where they are.
*
* The output uses classes of Bootstrap 4 and the icons of FontAwesome (Free)
**/
function onx_woocommerce_checkout_steps()
{
echo '<nav id="woo-checkout-steps" class="nav nav-pills nav-justified mb-4" role="navigation">';
@woogists
woogists / wc-change-email-subject.php
Last active December 29, 2022 13:52
Change email subject lines
/*
* goes in theme functions.php or a custom plugin
*
* Subject filters:
* woocommerce_email_subject_new_order
* woocommerce_email_subject_customer_processing_order
* woocommerce_email_subject_customer_completed_order
* woocommerce_email_subject_customer_invoice
* woocommerce_email_subject_customer_note
* woocommerce_email_subject_low_stock
@woogists
woogists / wc-exclude-product-category-from-shop-page.php
Last active December 29, 2022 13:49
[Frontend Snippets] Exclude products from a particular category on the shop page
/**
* Exclude products from a particular category on the shop page
*/
function custom_pre_get_posts_query( $q ) {
$tax_query = (array) $q->get( 'tax_query' );
$tax_query[] = array(
'taxonomy' => 'product_cat',
'field' => 'slug',
@kloon
kloon / woocommerce-3.3-hide-uncetagorized-category.php
Created February 9, 2018 05:30
WooCommerce 3.3 Hide uncategorized category from shop
<?php
add_filter( 'woocommerce_product_subcategories_args', 'remove_uncategorized_category' );
/**
* Remove uncategorized category from shop page.
*
* @param array $args Current arguments.
* @return array
**/
function remove_uncategorized_category( $args ) {
$uncategorized = get_option( 'default_product_cat' );
@tpaksu
tpaksu / renew.sh
Created January 19, 2018 07:35
laragon refresh certificates
#!/bin/sh
CRTPATH=$(pwd -W)
for i in *.key ; do
DOMAIN=${i%.key}
cat << EOF > openssl_$DOMAIN.conf
[req]
distinguished_name = req_distinguished_name
req_extensions = v3_req
prompt = no
[req_distinguished_name]
@hedqvist
hedqvist / functions.php
Created January 17, 2018 10:24
Add content after "Proceed to checkout"
<?php
/**
* @snippet WooCommerce - Add content after "Proceed to checkout" button via functions.php
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.2.5
*/
redlight_wc_cart_after_procced_to_checkout(){
$checkout_url = 'https://example.com/your-page/';
?>
<a href="<?php echo $checkout_url; ?>" class="checkout-button button alt wc-forward"><?php _e( 'Continue shopping', 'woocommerce' ); ?></a>
@hemraj7171
hemraj7171 / add_billing_address_on_registration_page.php
Created November 18, 2017 05:46
Add Billing fields in registration page WooCommerce
/**
* Add billing fields
*
*/
function my_custom_function(){
global $woocommerce;
$checkout = $woocommerce->checkout();
//print_r($checkout);
$checkout_fields = $checkout->checkout_fields['billing'];
unset( $checkout_fields['billing_email']);