Changing ‘Add to cart’ button text and relink for some specific products [closed]

Per Ashish’s answer that’s been posted, below is the update code for clarification with the correct answer by switching add_to_cart_url() to get_permalink(): global $product, $post; $hasCustomization = get_post_meta( $post -> ID, ‘_wcm_custom_design_checkbox’, true ); if ( $hasCustomization == ‘on’ ) { echo apply_filters( ‘woocommerce_loop_add_to_cart_link’, sprintf( ‘<a href=”https://wordpress.stackexchange.com/questions/237352/%s” rel=”nofollow” data-product_id=”https://wordpress.stackexchange.com/questions/237352/%s” data-product_sku=”https://wordpress.stackexchange.com/questions/237352/%s” class=”add_to_cart %s product_type_%s”>%s</a>’, esc_url( $product … Read more

How to make a shortcode with a line break in it parse correctly?

There are two workaround options I’ve found: Workaround 1: You can use an indiscriminate number of non-breaking spaces where you would like a line break. So to imitate this: [shortcode paraA1=’789′ paraB1=’987′ paraA2=’890′ paraB2=’098′ paraA3=’901′ paraB3=’109′ ] You can enter: [shortcode paraA1=’789′ paraB1=’987′ paraA2=’890′ paraB2=’098′ paraA3=’901′ paraB3=’109′ ] The WordPress text editor will wrap the … Read more

Meta box or shortcode help

First create the meta box with a simple input value to insert the text you want. Here is a good example. Then you take the input from the meta box and create a function to store it as a shortcode. Check out the Shortcode API to enable the shortcode. Something like this should do the … Read more