monthly invoices not generated
-
Hi guys, I am using this custom script to generate monthly invoices for a subscription product on my multivendor store. For the past 3 months the invoices are no longer auto-generated. I have to do this manually. A bit difficult with +300 vendors. I was wondering how I can check if the cron runs or how I can setup a custom cron for this on Plesk instead of using WP Cron?
// Send PDF Invoice only for Internal products // add_filter( 'wpo_wcpdf_document_is_allowed', function( $condition, $document ) { if ( $document->type == 'invoice' ) { if ( $document->exists() ) { return $condition; } $condition = false; if ( $order = $document->order ) { //Set categories here (comma separated) $not_allowed_cats = array( 'internal-products' ); $order_cats = array(); //Get order categories foreach ( $order->get_items() as $item_id => $item ) { // get categories for item, requires product if ( $product = $item->get_product() ) { $id = $product->get_parent_id() ? $product->get_parent_id() : $product->get_id(); $terms = get_the_terms( $id, 'product_cat' ); if ( empty( $terms ) ) { continue; } else { foreach ( $terms as $key => $term ) { $order_cats[$term->term_id] = $term->slug; } } } } // get array of category matches $cat_matches = array_intersect( $not_allowed_cats, $order_cats ); if ( count( $cat_matches ) > 0 ) { return true; // if there is 1 or more matches: allow invoice } } } return $condition; }, 10, 2 ); // Auto Complete all virtual orders add_action('woocommerce_order_status_changed', 'ts_auto_complete_virtual'); function ts_auto_complete_virtual($order_id) { if ( ! $order_id ) { return; } global $product; $order = wc_get_order( $order_id ); if ($order->data['status'] == 'processing') { $virtual_order = null; if ( count( $order->get_items() ) > 0 ) { foreach( $order->get_items() as $item ) { if ( 'line_item' == $item['type'] ) { $_product = $order->get_product_from_item( $item ); if ( ! $_product->is_virtual() ) { // once we find one non-virtual product, break out of the loop $virtual_order = false; break; } else { $virtual_order = true; } } } } // if all are virtual products, mark as completed if ( $virtual_order ) { $order->update_status( 'completed' ); } } }
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘monthly invoices not generated’ is closed to new replies.