Hide a Menu Item on Login

Can’t you change CSS rules? .hide-item-not-login{ display: block !important; } .logged-in .hide-item-not-login{ display: none !important; } EDIT To add login/logout menu item, you will need to add one more class to logout menu item. Let’s say you added class .logout-link to logout menu item. Then you can add css like this. .hide-item-not-login{ display: block !important; … Read more

How to add metabox ONLY to specific WooCommerce product type [closed]

You should be able to get the current product id using the using the $post global variable and use that with the WooCommerce function get_product() to the the product object and test its product type. public function __construct() { add_action( ‘add_meta_boxes’, array( $this, ‘add_meta_box’ ) ); } public function add_meta_box( $post_type ) { $post_types = … Read more

woo product , wp_insert_post() never displays on the front end. What gives? [closed]

Glad you got it to work! Per my comment, WooCommerce takes Post Meta into consideration whenever deciding whether or not to add a Product to the Shop Catalog. It seems you were able to make it show up by updating the product visibility: update_post_meta( $new_product_post_id, ‘_visibility’, ‘visible’ ); I’m not 100% familiar with WooCommerce so … Read more

Adding “reply-to” in the email [closed]

Not sure what the WC_Email class does exactly, but if the $headers argument is an array of headers, then you’re almost there. To interpolate a variable value into a string in PHP you don’t have to do the <?php … stuff because it’ll be rendered as is. Instead, you can use: $headers = array( “Reply-To: … Read more

How to display ACF taxonomy checkbox links on WooCommerce product category archive

The issue has been solved. See below for the correct code to display ACF multiple taxonomy links on WooCommerce product category archives. Specifically note the string: $related_terms = get_field(‘quick_links’, $taxonomy . ‘_’ . $term_id); $queried_object = get_queried_object(); $taxonomy = $queried_object->taxonomy; $term_id = $queried_object->term_id; $related_terms = get_field(‘quick_links’, $taxonomy . ‘_’ . $term_id); if( $related_terms ): ?> … Read more

Generate payment URL in custom email [closed]

The correct method for generating a payment URL is: get_checkout_payment_url() So my code changed to to: $payment_page = $order->get_checkout_payment_url(); Which generates the following URL: http://www.example.co.za/checkout/order-pay/[order-number]?pay_for_order=true&key=order_[order-key] Which is what I was looking for. Note that the order status must be set to unpaid or pending in order for the generated link to be valid

How to check if a product is purchased within the last 365 days before displaying something

This is not that complicated, here is a code snippet that will get you started: if(is_user_logged_in()) { //We only need these products to check $products_to_check = array(81,82,83,84); $customer_bought = array(); //Get all orders made by the current user in the last 365 days $customer_orders = get_posts( apply_filters( ‘woocommerce_my_account_my_orders_query’, array( ‘numberposts’ => $order_count, ‘meta_key’ => ‘_customer_user’, … Read more

How to order WP_Query to group results?

If your naming system is consistent then simply ordering by the post name should do it: $args = array( ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ); $q = new WP_Query($args); var_dump($q->request); var_dump(wp_list_pluck($q->posts,’post_title’)); Or, as a pre_get_posts filter (assuming the main query is what we want to alter): add_action( ‘pre_get_posts’, function ($qry) { if ($qry->is_main_query()) { … Read more