Skip to content

Instantly share code, notes, and snippets.

@jamesckemp
jamesckemp / woo-loop-custom-text.php
Last active November 29, 2017 01:28
Add some custom text (from an ACF field) to the product loop
<?php
/*
* Add this code to your functions.php file
*/
add_action( 'woocommerce_after_shop_loop_item_title', 'jck_custom_text', 15 );
function jck_custom_text() {
the_field('your_field_key');
@jamesckemp
jamesckemp / snippet.php
Created May 31, 2017 14:26
Remove X Theme catalog thumbnails
<?php
add_action( 'init', 'iconic_remove_x_theme_thumbnails' );
function iconic_remove_x_theme_thumbnails() {
remove_action( 'woocommerce_before_shop_loop_item_title', 'x_woocommerce_shop_product_thumbnails', 10 );
}
@jamesckemp
jamesckemp / example.php
Created November 17, 2017 13:02
Enable custom field for specific products
<?php
/**
* Output engraving field.
*/
function iconic_output_engraving_field() {
global $product;
if ( $product->get_id() !== 1741 ) {
return;
}
@jamesckemp
jamesckemp / crop.php
Created March 13, 2018 14:17
WooCommerce crop single image
<?php
/**
* Modify shop single sizes.
*
* @param array $size
*
* @return array
*/
function iconic_modifiy_shop_single( $size ) {
<?php
/**
* Don't redirect on archive pages.
*
* @param string $redirect
*
* @return string
*/
function iconic_add_to_cart_form_action( $redirect ) {
/**
* Get customer completed orders orders by email.
*
* @param string $email
*
* @return array
*/
function iconic_get_customer_completed_orders_by_email( $email ) {
$transient_name = sprintf( 'iconic_orders_by_email_%s', strtolower( esc_attr( $email ) ) );
@jamesckemp
jamesckemp / show-sku-search.php
Created September 19, 2019 10:57
Show product SKU when searching in WooCommerce
<?php
/**
* Show SKU on products when searching.
*/
function iconic_show_sku_search() {
if ( ! is_search() ) {
return;
}
/**
* Modify delivery slots labels.
*
* @param array $labels
* @param null|WC_Order $order
*
* @return array
*/
function iconic_modify_delivery_slots_labels( $labels, $order ) {
$chosen_shipping = $order ? iconic_get_order_shipping_method( $order ) : iconic_get_selected_shipping_method();
function iconic_remove_admin_redirect() {
remove_action( 'admin_init', array( 'JCK_SFR_User', 'redirect_voters' ), 10 );
}
add_action( 'init', 'iconic_remove_admin_redirect' );
function iconic_disable_qv_images() {
global $jckqv;
if ( empty( $jckqv ) ) {
return;
}
add_action( 'jck_qv_images', array( $jckqv, 'modal_part_images' ), 10, 3 );
}