Skip to content

Instantly share code, notes, and snippets.

View jhimross's full-sized avatar

Jhimross Olinares jhimross

View GitHub Profile
@jhimross
jhimross / gist:a832c3936ae942bce961b4639b157b68
Created January 27, 2022 04:41
Iconic Linked Variations - Force show out of stock Linked Variations
/**
* Iconic Linked Variations - Force show out of stock Linked Variations.
*
* @param array $product_data Product Data.
* @param int $product_id Product ID.
*
* @return array
*/
function iconic_lv_force_show_out_of_stock_products( $product_data, $product_id ) {
foreach ( $product_data['attributes'] as &$attribute ) {
@jhimross
jhimross / gist:4d5ea63301d2f63abef49044af06f4c2
Created January 27, 2022 04:45
Add Product SKU in WooCommerce Cart, Checkout, and Order Details
// First, let's write the function that returns a given product SKU
function iconic_return_sku( $product ) {
$sku = $product->get_sku();
if ( ! empty( $sku ) ) {
return '<p>SKU: ' . $sku . '</p>';
} else {
return '';
}
}
@jhimross
jhimross / gist:a824451cabb8f517218dbea890c609ff
Created January 27, 2022 04:47
Add Product Thumbnail Images in FluxCheckout
add_filter( 'woocommerce_cart_item_name', 'iconic_product_image_on_checkout', 10, 3 );
function iconic_product_image_on_checkout( $name, $cart_item, $cart_item_key ) {
/* Return if not checkout page */
if ( ! is_checkout() ) {
return $name;
}
/* Get product object */
@jhimross
jhimross / gist:a51cc486149ae3b99211e5d359806c3f
Created January 27, 2022 04:48
WooCommerce Attributes Swatches - Remove "From" in the pricing in Product Page
/**
* Remove "From %s" format of pricing.
*/
function iconic_was_remove_from() {
remove_filter( 'woocommerce_variable_price_html', array( 'Iconic_WAS_Fees', 'variable_price_html' ), 10, 2 );
}
add_action( 'init', 'iconic_was_remove_from' );
@jhimross
jhimross / gist:04eea2301aaccc39b9f45d4d7c8a0b7d
Created January 27, 2022 04:49
FluxCheckout - Translate "Back to Cart"
// Translate 'Back to Cart'
function translate_strings ( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Back to Cart' : // change text
$translated_text = __( 'Bumalik sa Cart', 'woocommerce' );
break;
}
return $translated_text;
}
add_filter( 'gettext', 'translate_strings', 20, 3 );
@jhimross
jhimross / gist:1510a2dcd5aea169bc8d98077bf19691
Created January 27, 2022 04:49
WooThumbs - Show Media Controls
jQuery('.iconic-woothumbs-responsive-media video').attr('controls',true);
@jhimross
jhimross / gist:51c1be7ebba3af069d983bf6b17f7950
Created January 27, 2022 04:51
WooCommerce Linked Variations - Add Linked Variations Swatches in the Catalog/Shop
// Add Iconic linked products to shop page
add_filter('woocommerce_loop_add_to_cart_link', 'wlv_add_swatch', 999);
function wlv_add_swatch() {
echo do_shortcode('[iconic_wlv_links]');
}
@jhimross
jhimross / gist:ed8a7392bab37ecf673adb598787a599
Created January 27, 2022 04:52
WooCommerce Delivery Slots - Change "ASAP" Text
/**
* Iconic WDS.
* Modify 'ASAP' label.
*
* @param string $label Label.
*
* @return string
*/
function iconic_wds_modify_asap_label( $label ) {
return 'As soon as possible'; // Change this value
@jhimross
jhimross / gist:5b674f2f21a6de702f0b30fecb35250f
Created January 27, 2022 04:54
WooCommerce Show Single Variations - Show Parent Product Description in Variations
/**
* Show parent's short description for variations.
*
* @param string $excerpt
* @param $post
*
* @return string
*/
function iconic_get_the_excerpt( $excerpt, $post ) {
if ( 'product_variation' !== $post->post_type ) {
@jhimross
jhimross / gist:0bfa2a6bd8c3be591a92c893b0e4d6d3
Created January 27, 2022 04:55
WooThumbs - Fix Flatsome Flickity Conflict
/**
*Iconic Attributes Swatches - dequeue flickity JS and CSS
*/
function iconic_was_dequeue_flickity(){
wp_dequeue_style( 'flickity' );
wp_dequeue_script( 'flickity' );
}
add_action( 'wp_enqueue_scripts','iconic_was_dequeue_flickity', 11);