Skip to content

Instantly share code, notes, and snippets.

@rad73
rad73 / woocommerce-single-product-functions.php
Created November 6, 2018 13:57 — forked from ohsoren/woocommerce-single-product-functions.php
Reorder the single product page product information
<?php
/**
* woocommerce_single_product_summary hook
*
* @hooked woocommerce_template_single_title - 5
* @hooked woocommerce_template_single_rating - 10
* @hooked woocommerce_template_single_price - 10
* @hooked woocommerce_template_single_excerpt - 20
* @hooked woocommerce_template_single_add_to_cart - 30
* @hooked woocommerce_template_single_meta - 40
<?php
//*** Support Title Tag
add_theme_support( 'title-tag' );
define('THEME_URI', get_template_directory_uri() );
define( 'THEME_PATH' , get_template_directory() );
// INCLUDE THEME FILE
@rad73
rad73 / functions.php
Created November 6, 2018 13:55 — forked from maddisondesigns/functions.php
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
@rad73
rad73 / change-single-page-layout.php
Created November 6, 2018 13:54 — forked from damiencarbery/change-single-page-layout.php
WooCommerce Single Page Layout - change it with just add_action()
<?php
/*
Plugin Name: Change Single Product Layout
Plugin URI: http://www.damiencarbery.com
Description: Change layout of Single Product page by changing add_action() order.
Author: Damien Carbery
Version: 0.1
*/
add_action( 'woocommerce_before_single_product', 'cspl_change_single_product_layout' );
@rad73
rad73 / functions.php
Created October 15, 2018 10:04 — forked from kontikidigital/functions.php
WooCommerce: Change Select Options Button Text for variable products
add_filter( 'woocommerce_product_add_to_cart_text' , 'custom_woocommerce_product_add_to_cart_text' );
/**
* custom_woocommerce_template_loop_add_to_cart
*/
function custom_woocommerce_product_add_to_cart_text() {
global $product;
$product_type = $product->product_type;
switch ( $product_type ) {
@rad73
rad73 / shortcode-for-cf7
Created October 14, 2018 21:13
Add shortcode to Contact Form 7
add_filter( 'wpcf7_form_elements', 'loc_wpcf7_form_elements' );
function loc_wpcf7_form_elements( $form ) {
$form = do_shortcode( $form );
return $form;
}
@rad73
rad73 / low-in-stock
Created October 14, 2018 21:13
"Hurry Up!" Text when WooCommerce Product low in stock
function loc_stock_in_shop() {
global $product;
if ( $product->stock ) {
if ( number_format($product->stock) < 3 ) {
echo '<div class="hurryup">Hurry up! Only ' . number_format($product->stock,0,'','') . ' left!</div>';
}
}
echo '<style>
.hurryup {
color: #ff0000 !important;
@rad73
rad73 / disable rss feed
Created October 14, 2018 21:13
Disable RSS feed
function loc_disable_feed() {
wp_die( __('Sorry. We do not use or have RSS.') );
}
add_action('do_feed', 'loc_disable_feed', 1);
add_action('do_feed_rdf', 'loc_disable_feed', 1);
add_action('do_feed_rss', 'loc_disable_feed', 1);
add_action('do_feed_rss2', 'loc_disable_feed', 1);
add_action('do_feed_atom', 'loc_disable_feed', 1);
@rad73
rad73 / excluding tags from tag cloud
Created October 14, 2018 21:13
Exclude tags from tag-cloud
add_filter( 'widget_tag_cloud_args', 'loc_exclude_tag');
function loc_exclude_tag( $args ) {
$args[ 'exclude' ] = '1,2,3,4,5';
return $args;
}
@rad73
rad73 / GETTEXT translation for any WP or WOO string
Created October 14, 2018 21:12
GETTEXT translation for any WP or WOO string
add_filter( 'gettext', 'loc_woo_translate', 999 );
function loc_woo_translate( $translated ) {
$translated = str_ireplace( 'Out of stock', 'Coming Soon!', $translated );
return $translated;
}