PHP Code Snippets/Functions

Use a shortcode to add a custom product attribute.

Insert this code into functions.php function custom_product_attributes_shortcode() { ob_start(); global $product; // Check if we’re on a single product page if ( is_product() ) { echo ‘<div class=”product-specs selected-attributes-info”>’; // Get the product attributes $attributes = $product->get_attributes(); $attribute_count = count( $attributes ); if ( $attribute_count === 0 || $attribute_count <= 2 ) { echo ‘<p>Not […]

PHP Code Snippets/Functions

Customize the product layout with specific attributes.

Insert this code into functions.php remove_action( ‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_template_loop_price’, 10 ); add_action(‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_after_shop_loop_item_title_custom’, 10); function woocommerce_after_shop_loop_item_title_custom() { global $product; $attributes = $product->get_attributes(); $colors = $attributes[“pa_color”]; $weight = $attributes[“pa_fabric-weight”]; $width = $attributes[“pa_fabric-width”]; $attributes = $product->get_attributes(); $attribute_count = count( $attributes ); if( $colors ){ $colorTerms = $colors->get_terms(); $selectedAttributesCount = count( $colorTerms ); echo ‘<div class=”product-attributes”>’; echo ‘<span class=”product-attributes-text” […]

CSS Code Snippets JS Code Snippets/Functions PHP Code Snippets/Functions

Change the Woocommerce “Add to Cart” total item notification to “Total Product Entry.”

Insert this code into the functions.php function child_theme_enqueue_styles() { // cart page wp_localize_script( ‘global-js’, ‘customMiniCartParams’, array( ‘totalUniqueProducts’ => custom_get_total_unique_products_in_cart(), ) ); } // Modify your PHP function to return the total unique products as a JavaScript variable function custom_get_total_unique_products_in_cart() { $total_unique_products = 0; // Get the cart contents $cart = WC()->cart->get_cart(); // Create an array […]

JS Code Snippets/Functions PHP Code Snippets/Functions

How to make jetpack testimonial into slider

In this tutorial you learn how to make your jetpack testimonial into a slider. (note: This tutorial assumes that you have already enable the testimonial settings on jetpack) Requirements: note: this is assuming that you have added the script and styles of the slick slider. If you have any question just contact the author of […]