Remove “?add-to-cart=product-id” from Add to Cart URL when on the Cart page

The solution would be to lose the ?add-to-cart=25part of the URL. The simplest way to do that is with javascript History API: history.pushState(null, “”, location.href.split(“?”)[0]); Docs: https://developer.mozilla.org/en-US/docs/Web/API/History_API The DOM window object provides access to the browser’s history through the history object. It exposes useful methods and properties that let you move back and forth through … Read more

How to get woocommerce product collection in template file

I found like this. For More : https://docs.woocommerce.com/document/sample-products-loop/ https://www.philowen.co/blog/show-latest-woocommerce-products-in-your-template/ <?php $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 12 ); $loop = new WP_Query( $args ); if ( $loop->have_posts() ) { while ( $loop->have_posts() ) : $loop->the_post(); wc_get_template_part( ‘content’, ‘product’ ); endwhile; } else { echo __( ‘No products found’ ); } wp_reset_postdata(); ?> Just … Read more

how to create additional button on single product page

To achieve something like this you should change the woocommerce_after_shop_loop_item hook, which is where the add to cart button is added. To replace it with custom behavior, first, you remove the button, then add your custom button in its place. add_action( ‘init’, ‘remove_add_to_cart_button’ ); function remove_add_to_cart_button() { remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’, 10 ); } add_action( ‘woocommerce_after_shop_loop_item’, … Read more

Show add to cart button and quantity field when no price is entered [closed]

Have you looked at the following? https://wordpress.stackexchange.com/a/104783/77202 From the answer above the following will always set the price to default to 0 when creating/updating a product function wpa104760_default_price( $post_id, $post ) { if ( isset( $_POST[‘_regular_price’] ) && trim( $_POST[‘_regular_price’] ) == ” ) { update_post_meta( $post_id, ‘_regular_price’, ‘0’ ); } } add_action( ‘woocommerce_process_product_meta’, ‘wpa104760_default_price’ … Read more

Woocommerce Slow Queries

Yep, three things. A) You have bot or an a**hole webscraper crawling your site and making a ton of bunk checkout caches. You need to invest in a web application firewall like Sucuri or Wordfence (use the paid version, not the free one in either case). If you don’t do this, you are going to … Read more

Override static method in WC_Shortcodes class (shortcode) [closed]

This is how you can (or should) remove the default Shortcode: // Hook after `WC_Shortcodes::init()` is executed. add_action( ‘init’, function(){ // Remove the shortcode. remove_shortcode( ‘product_categories’ ); // Add it back, but using our callback. add_shortcode( ‘product_categories’, ‘my_product_categories_shortcode’ ); }, 11 ); And here’s how you can modify the default Shortcode’s output: function my_product_categories_shortcode( $atts … Read more

Can’t remove woocommerce sidebar

First, most themes have multiple page templates you can choose from. Please check: go to cart page (in wp-admin). See side metabox ‘Page Attributes’. There you can set the page template, does it have something like ‘full_width’? You can also try a different hook, like wp_head. Example: add_action( ‘wp_head’, ‘urun_sidebar_kaldir’ ); Let me know. After … Read more