E-commerce Code Snippets

Here you'll find certain snippets to do some general common stuff in Themify themes. Note that some snippets might not work in all themes.

General procedure to use a snippet

1. Create a file named custom-functions.php in your theme root folder
2. Edit it, and paste this inserting the snippet you've chosen


// Snippet code goes here


3. Save the file. If you were editing it locally, upload it by FTP to the theme folder in your server.

When you already have a custom-functions.php, you only need to add the PHP code inside the <?php and ?> tags.

E-commerce themes: replace link to add to cart, with a link to product details.


 * Replace default link that adds product to cart with a link to product single view labeled Read More
 * @param $html
 * @param $product
 * @param $link
 * @return string
function custom_themify_woocommerce_loop_add_to_cart_link( $html, $product, $link ) {
    return sprintf('<a href="%s" rel="nofollow" data-product_id="%s" data-product_sku="%s" class="button product_type_%s">%s</a>', get_permalink( $product->id ), esc_attr( $product->id ), esc_attr( $product->get_sku() ), esc_attr( $product->product_type ), __('Read More', 'themify') );
add_filter('woocommerce_loop_add_to_cart_link', 'custom_themify_woocommerce_loop_add_to_cart_link', 10, 3);


Father's Day Sale: Get up to 30% off code: SUPERDAD & $100 off Lifetime Club with code: DAD4LIFE