Show audio player only in specific post type category

Have you tried has_category? You can add a check to make sure the post has the specified category. If not then return the content un changed like below: <?php add_filter( ‘woocommerce_short_description’, ‘wpse_67108_autplay_music’ ); function wpse_67108_autplay_music( $content ) { if ( ! is_singular( ‘product’ ) && ! has_category( ‘<your specific category here>’ )) { return $content; … Read more

Run a sql (update) after 12 hours after the user login. Woocommerce users

You could do something like this (this code has not been testedt). function schedule_sql_command($user_login, $user) { // 12 hours in seconds. $from_now = 12 * 60 * 60; // schedule a call to a custom hook passing in the user’s ID wp_schedule_single_event(time() + $from_now, ‘run_sql_command’, array( $user->ID) ); } // this is the custom hook … Read more

How to access product’s meta data when deleting a WooCommerce product?

Finally got this working. add_action(‘before_delete_post’, ‘removeCheckDetail’, 10, 1 ); function removeCheckDetail( $order_id ) { global $woocommerce; global $wpdb; $order = new WC_Order($order_id); $order_items = $order->get_items(); // Loop through order line items foreach( $order_items as $item_id => $item ) { $url = $item->get_meta(‘Check Detail’); parse_str( parse_url( $url, PHP_URL_QUERY), $array ); $key = strstr($array[‘ck_item’], ‘”‘, true); $wpdb->check_detail … Read more

One Time Access URL after purchasing subscription

A simple solution would be creating a unique token upon purchasing a subscription/product. Save to token somewhere in database. Present the URL to the app passing the token as a GET variable. For eample, www.company.com/app/the-awesome-tool/?token=jvp2HBst5V7iHQeE2twq When accessed, check is the token is there at the database, if not restrict access. Delete the token from database … Read more

Display “Add to basket” and “Read more” buttons in the products shop page with woocommerce

Would something like this achieve what you are after? Could be refined more by using the default read more function rather than echoing it. function add_extra_read_more_btn() { global $product; if ($product->is_purchasable()) { echo ‘<div class=”woocommerce-LoopProduct-buttons-container”>’; echo ‘<a class=”button product_type_simple” href=”‘.get_permalink($product->ID).'”>Read more</a>’; } } add_action( ‘woocommerce_after_shop_loop_item’, ‘add_extra_read_more_btn’, 9 ); function close_extra_read_more_btn_wrap() { global $product; if ($product->is_purchasable()) … Read more