How does perch_shop_purchased_files(); work?

  • The function lists the files a logged in customer has purchased. You can use it to list purchased files for all the customer's orders or for a single order:


    PHP
    1. // list purchased files for all customer orders
    2. perch_shop_purchased_files();
    3. // list purchased files for a single order
    4. perch_shop_purchased_files([
    5. 'order' => $orderID,
    6. ]);
  • Yeah, I'd seen that in the docs - but it doesn't show anything.


    Steps I've undertaken so far:


    1. Added two files to a product using the files tab in the product admin (files.list.post.php).

    2. Order the product through the system

    3. Added the code to the order view


    PHP
    1. <?php
    2. perch_shop_purchased_files();
    3. perch_shop_purchased_files([
    4. 'order' => $orderID,
    5. ]);
    6. perch_shop_order($orderID, [
    7. 'template' => '/shop/orders/order_better.html'
    8. ]);
    9. ?>

    The perch_shop_order shows the order fine, but the files functions do not show anything?


    There are no errors in the debug, and the standard file.html and files_list.html are in the templates folder?


    Could this be because the product ordered is a variant?

  • As suspected:


    If the product purchased is a variant the download(s) are not associated to the order.


    If the product is singular, the download is associated as expected.


    This isn't what I expected, but at least I now understand what's happening.