How to put a date range in a virtual/downloadable product? [closed]

Hook into add_to_cart hook add_action(‘woocommerce_add_to_cart’, ‘create_files_for_cart’); function create_files_for_cart() { // Your code that created the file using the dated the user selected // More code to add the file created to cart } The code to create the downloadable file product is similar to the code in this answer Add the product to cart with … Read more

WooCommerce breadcrumb display custom posts instead of product data

The solution is quite simple. I copied single-product.php from woocommerce/templates and modified it so loop starts before before_main_content hook: get_header( ‘shop’ ); ?> <?php while ( have_posts() ) : the_post(); ?> <?php /** * woocommerce_before_main_content hook. * * @hooked woocommerce_output_content_wrapper – 10 (outputs opening divs for the content) * @hooked woocommerce_breadcrumb – 20 */ do_action( … Read more

how to retrieve post_id under woocommerce_add_to_cart_validation hook?

woocommerce_add_to_cart_validation passes the product id as the second argument to the callback function, so you can access it like this: function custom_fields_validation( $passed_validation, $product_id ) { if( isRecurring( $product_id ) ) { if ( empty( $_POST[‘inputday’]) ){ wc_add_notice( __( ‘Please select field 1;’, ‘woocommerce’ ), ‘error’ ); return false; } if ( empty( $_POST[‘inputtime’] )){ … Read more

Category_in return empty

You can achieve that using the tax_query, see the example in the code below: $args = array( ‘posts_per_page’ => 10, ‘post_type’ => ‘product’, ‘post_status’ => ‘publish’, ‘tax_query’ => array( ‘taxonomy’ => ‘the_taxonomy_slug’, //the slug of the taxonomy you want to get ‘field’ => ‘term_id’, ‘terms’ => $categories ) ); See reference in the Codex

Rewrite URL to get rid of wp-content etc and change URL

$matches[1] doesn’t work for external redirects, only internal (URL must start with index.php and handled by WordPress itself) Try this add_action(‘init’, ‘custom_rewrite_pdfURL’); function custom_rewrite_pdfURL() { add_rewrite_rule(‘^carPDF/([^/]*)/?’, ‘wp-content/themes/exampletheme/templates/pdf-generator.php?productID=$1’, ‘top’); } Don’t forget to flush permalinks