Skip to content

Instantly share code, notes, and snippets.

View Spirecool's full-sized avatar

Jérôme OLLIVIER Spirecool

View GitHub Profile
We couldn’t find that file to show.
1 - PHP
<?php
add_action( 'woocommerce_single_product_summary', 'bbloomer_show_return_policy', 20 );
function bbloomer_show_return_policy() {
echo '<p class="rtrn">30-day return policy offered. See Terms and Conditions for details.</p>';
}
<?php
add_action( 'woocommerce_single_product_summary','bloomer_echo_product_date',25 );
function bloomer_echo_product_date() {
if ( is_product() ) {
echo the_date('', '<span class="date_published">Published on: ', '</span>', false);
}
}
1 - PHP
<?php
add_action( 'woocommerce_before_single_product', 'bbloomer_prev_next_product' );
// and if you also want them at the bottom...
add_action( 'woocommerce_after_single_product', 'bbloomer_prev_next_product' );
function bbloomer_prev_next_product(){
<?php
add_action( 'woocommerce_before_single_product', 'bbloomer_show_video_not_image' );
function bbloomer_show_video_not_image() {
// Do this for product ID = 282 only
if ( is_single( '282' ) ) {
remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
remove_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );
<?php
function woocommerce_quantity_input( $args = array(), $product = null, $echo = true ) {
if ( is_null( $product ) ) {
$product = $GLOBALS['product'];
}
$defaults = array(
'input_id' => uniqid( 'quantity_' ),
1 - PHP
<?php
// -------------
// 1. Show Buttons
add_action( 'woocommerce_before_add_to_cart_quantity', 'bbloomer_display_quantity_plus' );
function bbloomer_display_quantity_plus() {
WooCommerce product add-ons are custom input fields that show on the single product page. They’re called “add-ons” as you can add a product personalization or an upsell (at a cost of course).
For example, you can display a text input to print something on the product. Or radio buttons to select different kinds of product upgrades. Or a checkbox to upsell gift wrapping.
<?php
/ -----------------------------------------
// 1. Show custom input field above Add to Cart
add_action( 'woocommerce_before_add_to_cart_button', 'bbloomer_product_add_on', 9 );
PHP Snippet 1: Move (a.k.a. remove, then re-add) Product Upsells Under Add to Cart @ Single Product Page
<?php
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_upsell_display', 39 );
?>
PHP Snippet 2: Change Product Upsells Output to 2 Columns @ Single Product Page
<?php
We couldn’t find that file to show.