How to make a custom redirect in WooCommerce?

add_action(‘template_redirect’, ‘woo_custom_redirect’); function woo_custom_redirect($redirect) { // HERE set your product category (can be term IDs, slugs or names) $category = ‘subscription’; $found = false; // CHECK CART ITEMS: search for items from our product category foreach(WC() – > cart – > get_cart() as $cart_item) { if (has_term($category, ‘product_cat’, $cart_item[‘product_id’])) { $found = true; break; } … Read more

Get user active posts randomly

But i can’t pass an array to it.I have a solution for getting the post randomly if am able to remove array elements form $user_ids by checking with product ids. Yes, the wc_customer_bought_product() function only accepts a single user/product ID. But you can loop through the $user_ids array, and for each user (ID), loop through … Read more

Add button linked to single product page on order detail page

The woocommerce_order_details_after_order_table hook receives the WC_Order object as the $order argument. This means you can get the items from the order with $order->get_items(). That will return an Array of WC_Order_Items. From this you can get the associated product of the first item, which you can use to get its permalink, to which you can append … Read more

email address non required

WooCommerce has a very broad documentation, one topic in it is about Customizing checkout fields using actions and filters, you can easily set billing_email to not be required. (code untested) add_filter(‘woocommerce_checkout_fields’, ‘WPSE0309_woocommerce_checkout_fields’); function WPSE0309_woocommerce_checkout_fields( $fields ) { $fields[‘billing’][‘billing_email’][‘required’] = false; return $fields; }

Awesome Support Custom Field for show Woocommerce orders

I found in documentation Checkbox, Radio and Select-Only Parameters $options (array): An array of options. The array must be or the form array( ‘option_id’ => ‘Option Label’ ) Example wpas_add_custom_field( ‘my_field_with_options’, array( ‘title’ => ‘My Options’, ‘options’ => array( ‘option1’ => ‘First Option’, ‘option2’ => ‘Second Option’), ‘order’ => 1 ) ); You add the … Read more

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