AyeCode / invoicing

GetPaid (Formerly the Invoicing plugin) is a lightweight Payments and Invoicing system for WordPress. It can be used to sell anything online via payment forms or buy now buttons that can be added to any landing page. It can also be used by freelancers to manage their Invoices or by 3rd party Themes and Plugins as their payment system. GeoDirectory currently uses GetPaid as its payment system
https://wpgetpaid.com/
Other
37 stars 23 forks source link

List All Items On One Page with their buy link using shortcode #729

Closed ikishorkumar closed 1 year ago

ikishorkumar commented 1 year ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

ikishorkumar commented 1 year ago

Solution : Here is the code to list all items using short code but there something missing i can't make to open the item page

<?php

// Define the shortcode function
function wpip_list_items_shortcode() {
    // Query the database for all items with the post type "wpi_item"
    $items = new WP_Query(array(
        'post_type' => 'wpi_item',
    ));

    // Start the output variable with an opening unordered list tag
    $output = '<ul'.' '.'id=itemsListall >';

    // Loop through the items and add them to the output variable
    if ( $items->have_posts() ) {
        while ( $items->have_posts() ) {
            $items->the_post();
            $output .= '<li>';
            $output .= '<h2>' . get_the_title() . '</h2>';
            $output .= '<p>' . get_the_content() . '</p>';
            $output .= do_shortcode('[getpaid item=' . get_the_ID() . ' button="Clear Dues"]');

            $output .= '</li>';
        }
    }

    // Add a closing unordered list tag to the output variable
    $output .= '</ul>';

    // Reset the post data
    wp_reset_postdata();

    // Return the output variable
    return $output;
}

// Register the shortcode
add_shortcode( 'wpip_list_items', 'wpip_list_items_shortcode' );

?>