Perch Shop Show Shipping and Billing Address on Order

  • Hello,


    I'm trying to show the shipping and billing address of an specific order. I have found reference to:


    perch_shop_customer_address();
    perch_shop_customer_addresses();


    The former accepts an array of options, but I cannot find any documentation on what these options are?


    My goal is to show the shipping and billing address based on a particular order ID.


    Could someone explain how this is done please...

  • OK, I think I have it:


    When an order is created, the system will assign an ID to the shipping address, and a separate ID to the billing address. You can see names of these id's in the showall table for the order. They are:


    orderShippingAddress

    orderBillingAddress


    The value will be an integer, for example:


    perch_shop_customer_address(29);


    '29' is the value stored for the billing address.


    orderShippingAddress 30
    orderBillingAddress 29



    To obtain this number, you will need call the order details into a specific template containing only that ID, for example:

    Code
    1. $billingAddress = perch_shop_order($orderID, [
    2.     'template' => '/shop/orders/billingAddress.html'
    3. ], true);


    The template billingAddress.html contains only the following ID:

    Code
    1. <perch:shop id="orderBillingAddress" />


    You can then use the value stored in $billingAddress to display the address:

    Code
    1. perch_shop_customer_address($billingAddress);


    Same logic applies for shipping address.