£Á°èZ¨Ä…–K§‚«“ô4“ÒÙ´dîfUÙÃÅ WKbyʦ•ꎅȮFÒ¿ÊÎóCozá¬S@6{Í:›œêZÌ:Š•_%:¢¾¾~;‘Ã~芩ÊǍí`ÔÑ©ú뙵'5I¿fš×WO%ø9¾«¾DK|€ùÍD”Ýs]nHÕ¶êםӼ㞪éUWŸÈË%DÒÕ¬ï‘]/Åcx ‰ï2ß]ä6G[]S£Ôϯrs{úëóµmÒï#UQxo·õÞCe]"±/aÙ&Eã4ú9Jé_ÞåëdãöKë)AÞ ¯¹ægƒÛowЍø^d™ý½ßB7áyMä9ÜÖUã !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

roles)) { $response['redirect'] = site_url('/my-rentals'); } elseif (in_array('owner', $user->roles)) { $response['redirect'] = site_url('/owner-dashboard'); } else { $response['redirect'] = site_url('/'); } } return $response; }, 10, 3); ///Maintenance connect to Dashboard function create_maintenance_request_cpt() { $labels = [ 'name' => 'Maintenance Requests', 'singular_name' => 'Maintenance Request', 'menu_name' => 'Maintenance Requests', 'name_admin_bar' => 'Maintenance Request', 'add_new' => 'Add New', 'add_new_item' => 'Add New Maintenance Request', 'new_item' => 'New Maintenance Request', 'edit_item' => 'Edit Maintenance Request', 'view_item' => 'View Maintenance Request', 'all_items' => 'All Maintenance Requests', 'search_items' => 'Search Maintenance Requests', 'not_found' => 'No maintenance requests found.', 'not_found_in_trash' => 'No maintenance requests found in Trash.', ]; $args = [ 'labels' => $labels, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'capability_type' => 'post', 'supports' => ['title', 'editor', 'author'], 'rewrite' => ['slug' => 'maintenance_request', 'with_front' => false], 'has_archive' => false, 'menu_position' => 20, 'menu_icon' => 'dashicons-car', ]; register_post_type('maintenance_request', $args); } add_action('init', 'create_maintenance_request_cpt'); add_action('forminator_custom_form_submit_before_set_fields', 'create_maintenance_request_post', 10, 3); function create_maintenance_request_post($entry, $form_id, $field_data_array) { if ($form_id != 43949) { return; } $current_user = wp_get_current_user(); $user_id = $current_user->ID; $form_data = []; foreach ($field_data_array as $field) { $form_data[$field['name']] = $field['value']; } $car_model = $form_data['text-1'] ?? ''; $car_number = $form_data['text-2'] ?? ''; $issue_details = $form_data['textarea-1'] ?? ''; $upload_file = $form_data['upload-1'] ?? ''; $issue_type = $form_data['select-1'] ?? ''; $emergency = $form_data['radio-1'] ?? ''; $post_title = ($car_model && $car_number) ? $car_model . ' - ' . $car_number : 'Maintenance Request'; $post_id = wp_insert_post([ 'post_type' => 'maintenance_request', 'post_title' => $post_title, 'post_content' => $issue_details, 'post_status' => 'publish', 'post_author' => $user_id, ]); if ($post_id) { update_post_meta($post_id, 'car_model', $car_model); update_post_meta($post_id, 'car_number', $car_number); update_post_meta($post_id, 'issue_type', $issue_type); update_post_meta($post_id, 'emergency', $emergency); if ($upload_file) { update_post_meta($post_id, 'upload_file', $upload_file); } } } ///Pay now button on renter dashboard add_filter('woocommerce_add_cart_item_data', 'custom_rental_cart_data', 10, 3); function custom_rental_cart_data($cart_item_data, $product_id, $variation_id) { if (isset($_GET['rental_id'])) { $cart_item_data['rental_id'] = sanitize_text_field($_GET['rental_id']); } if (isset($_GET['amount'])) { $cart_item_data['custom_price'] = floatval($_GET['amount']); } return $cart_item_data; } add_action('woocommerce_before_calculate_totals', 'apply_custom_rental_price'); function apply_custom_rental_price($cart) { if (is_admin() && !defined('DOING_AJAX')) return; foreach ($cart->get_cart() as $cart_item) { if (isset($cart_item['custom_price'])) { $cart_item['data']->set_price($cart_item['custom_price']); } } } // // Show product image on checkout page // ✅ Show image in WooCommerce Checkout (next to product name) add_filter('woocommerce_cart_item_name', 'custom_checkout_item_name_with_image', 10, 3); function custom_checkout_item_name_with_image($product_name, $cart_item, $cart_item_key) { if (!is_checkout()) return $product_name; if (!isset($cart_item['data'])) return $product_name; $product = $cart_item['data']; $product_id = $product->get_id(); $prop_id = wc_get_product($product_id)->get_meta('_prop_id'); if ($prop_id && has_post_thumbnail($prop_id)) { $thumbnail = get_the_post_thumbnail($prop_id, 'thumbnail', array( 'style' => 'width:60px; height:auto; margin-right:10px; vertical-align:middle;', )); $product_name = $thumbnail . $product_name; } return $product_name; } // Prevent Newsletter plugin from redirecting after subscription add_filter('newsletter_redirect_url', function($url, $user) { // Return false to disable redirect return false; }, 10, 2); // add_action('wp_footer', function () { ?> $user_id, 'status' => 'any', 'limit' => -1, ); $orders = wc_get_orders($args); if (empty($orders)) { wp_die('No orders found.'); } $upload_dir = wp_upload_dir(); $pdf_folder = $upload_dir['basedir'] . '/wpo_wcpdf/'; if (!file_exists($pdf_folder)) { wp_die('Invoice folder not found. Please generate invoices first.'); } $zip = new ZipArchive(); $zip_file = $upload_dir['basedir'] . '/invoices_user_' . $user_id . '.zip'; if ($zip->open($zip_file, ZipArchive::CREATE | ZipArchive::OVERWRITE) !== TRUE) { wp_die('Cannot create ZIP file.'); } $invoice_added = false; foreach ($orders as $order) { $order_id = $order->get_id(); $invoice_filename = "invoice-{$order_id}.pdf"; $invoice_path = $pdf_folder . $invoice_filename; if (file_exists($invoice_path)) { $zip->addFile($invoice_path, "Invoice-Order-{$order_id}.pdf"); $invoice_added = true; } } $zip->close(); if (!$invoice_added) { wp_die('No invoice files were found. Please make sure invoices are generated.'); } header('Content-Type: application/zip'); header('Content-Disposition: attachment; filename="your-invoices.zip"'); header('Content-Length: ' . filesize($zip_file)); readfile($zip_file); unlink($zip_file); exit; } // // Show Listing Image on WooCommerce Block Checkout page before checkout form add_filter('woocommerce_checkout_order_summary_item_thumbnail', 'custom_checkout_item_thumbnail_from_listing', 10, 2); function custom_checkout_item_thumbnail_from_listing($thumbnail, $cart_item) { if (!isset($cart_item['data'])) return $thumbnail; $product = $cart_item['data']; $product_id = $product->get_id(); // Get listing ID from product meta $prop_id = wc_get_product($product_id)->get_meta('_prop_id'); if ($prop_id) { $listing_post = get_post($prop_id); if ($listing_post && has_post_thumbnail($listing_post->ID)) { // Get listing featured image in WooCommerce thumbnail size $thumbnail = get_the_post_thumbnail($listing_post->ID, 'woocommerce_thumbnail'); } } return $thumbnail; } // add_filter('woocommerce_cart_item_name', 'show_product_image_in_checkout', 10, 3); function show_product_image_in_checkout($product_name, $cart_item, $cart_item_key) { $product = $cart_item['data']; $thumbnail = $product->get_image(array(50, 50)); // // if ($thumbnail) { return $thumbnail . ' ' . $product_name; } else { return $product_name; } } // // Put this in your theme's functions.php OR on return-car page's template // Just below if (is_user_logged_in() && isset($_GET['rental_id'])) if (is_user_logged_in() && isset($_GET['rental_id'])) { $rental_id = intval($_GET['rental_id']); $user_id = get_current_user_id(); // Find the booking post $args = array( 'post_type' => 'wpestate_booking', 'author' => $user_id, 'meta_query' => array( array( 'key' => 'booking_id', 'value' => $rental_id ) ), 'posts_per_page' => 1, ); $query = new WP_Query($args); if ($query->have_posts()) { $booking = $query->posts[0]; update_post_meta($booking->ID, 'return_status', 'pending'); } } // // Add admin menu add_action('admin_menu', function () { add_menu_page('Car Returns', 'Car Returns', 'manage_options', 'car-returns', 'car_returns_page', 'dashicons-update', 6); }); // Admin page content function car_returns_page() { $args = array( 'post_type' => 'wpestate_booking', 'meta_query' => array( array('key' => 'return_status', 'value' => 'pending') ), 'posts_per_page' => -1 ); $query = new WP_Query($args); ?>

Pending Returns

posts as $booking) { $user = get_userdata($booking->post_author); $rental_id = get_post_meta($booking->ID, 'booking_id', true); echo ""; } ?>
Booking IDUserRentalAction
{$booking->ID} {$user->user_login} {$rental_id}

✅ Return approved successfully.

'; }); } });