Add Additional “Checkout” button next to “Add to cart” button in woocommerce product page

You dont need to modify your template files for this, instead you can use the WooCommerce hook woocommerce_after_add_to_cart_button. This hook will add content after the “Add to cart” button. If the customer clicks on this button, the product should get added to the cart, and the customer should be send to the checkout page, right?! … Read more

WooCommerce Template overriding not working with woocommerce.php

It’s a custom theme, so first of all you should check if WooCommerce support is declared in the functions.php. WooCommerce can be integrated with the theme by using woocommerce_content() (woocommerce.php file) or by template overrides, but in both cases the declaration of support in the theme is required. function wpse319485_add_woocommerce_support() { add_theme_support( ‘woocommerce’ ); } … Read more

WooCommerce add_to_cart() with custom price [closed]

Currently there is no straight way to add custom price to product which is added through function $woocommerce->cart->add_to_cart (Documentation) but we have a bypass way that i explain in code below global $woocommerce; $custom_price = 1000; // Cart item data to send & save in order $cart_item_data = array(‘custom_price’ => $custom_price); // woocommerce function to … Read more

Add Custom CSS to Woocommerce Product Page in a specified category

Here’s my solution… Added the following to functions.php in my child theme: add_filter( ‘body_class’,’my_body_classes2′ ); function my_body_classes2( $classes ) { if ( is_product() ) { global $post; $terms = get_the_terms( $post->ID, ‘product_cat’ ); foreach ($terms as $term) { $product_cat_id = $term->term_id; $classes[] = ‘product-in-cat-‘ . $product_cat_id; } } return $classes; } Now whenever you’re viewing … Read more

How to show “Previous Category” and “Next Category” in categories archieve template [closed]

This is about PHP, not about WordPress, but here you go: get_categories returns a simple array of categories, not an indexed array. Your foreach loop tries to adress it as an indexed array. Hence the error. Also, $position becomes an undefined variable, and the loop is unnecessary anyway. $position = array_search ($this_category->term_id, $categories); $next_cat = … Read more

pre_get_posts with WooCommerce Shortcode Query

You could use the WooCommerce filter woocommerce_shortcode_products_query to change/manipulate the query arguments. This example comes from the shortcode documentation. When using the Products shortcode, you can choose to order products by the pre-defined values above. You can also sort products by custom meta fields using the code below (in this example we order product by … Read more

Hide Add to Cart Button

Just add the following code in your functions.php and you will find button hidden I don’t know whether my solution is perfect. But it works. Normally if is_purchasable is returned to the filter woocommerce_is_purchasable, the ‘Add to Cart’ button is displayed, and if false is returned the button is hidden. So, you just need to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)