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

WooCommerce multiple custom fields code

Not in stackoverflow nor stackexchange can`t answer my question. I dont know maybe they just can edit my writing dictation!. Anyway after searching in php courses my code is this now and works correctly: <?php $custom_field_type = get_post_meta($post->ID, ‘_custom_field_type’, true); $custom_field_type = array_filter($custom_field_type, ‘strlen’); if (count($custom_field_type)) { echo ‘<div id=”vijegiha”>’; echo ‘<h3 id=”vijegih3″>ویژگی های کلیدی</h3>’; … 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

Not displaying Woocommerce product page in lightbox

you are adding the name of product in a’s tag of href <a class=”modal-link” href=”https://wordpress.stackexchange.com/product/” . $wslug . ‘”/>View</a> you need to add products html link in this like below <a class=”modal-link” href=”https://wordpress.stackexchange.com/questions/312841/example.html”/>View</a> i hope it work. lightbox link ex: <a href=”http://www.yoursite.com/yourpage.htm” class=”html5lightbox” data-width=”960″ data-height=”600″>Link to Page</a>