Forum

Thread tagged as: Question, Shop

Get addresses assigned to cart just before payment

Hi,

I'm trying to display the addresses chosen on a final confirmation page before going off to Paypal with an option that the customer can go back to the stage where they choose their address for the current cart. Is it possible to get the ids of the addresses associated with the cart once perch_shop_addresses_set() is returning true?

Many thanks, Paul

Paul Ellis

Paul Ellis 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

The billing and shipping addresses are held in the cart, so you can call perch_shop_cart() with the skip-template option to get all that back.

Hi, thanks for your reply. I had tried that but couldn't see the elements that hold the addresses (or references to them). Here is what I get returned from $cartinfo = perch_shop_cart(['skip-template' => true,]); :

array (size=52)
  'discount_code' => null
  'promotions' => 
    array (size=0)
      empty
  'product_count' => string '1' (length=1)
  'item_count' => string '1' (length=1)
  'items' => 
    array (size=1)
      0 => 
        array (size=21)
          'discount' => int 0
          'price_with_tax' => string '15.00' (length=5)
          'price_with_tax_formatted' => string '£15.00' (length=7)
          'price_without_tax' => string '15.00' (length=5)
          'price_without_tax_formatted' => string '£15.00' (length=7)
          'tax' => string '0.00' (length=4)
          'tax_discount' => int 0
          'tax_formatted' => string '£0.00' (length=6)
          'tax_rate' => string '0.00' (length=4)
          'total_tax' => string '0.00' (length=4)
          'total_tax_formatted' => string '£0.00' (length=6)
          'total_with_tax' => string '15.00' (length=5)
          'total_with_tax_formatted' => string '£15.00' (length=7)
          'total_without_tax' => string '15.00' (length=5)
          'total_without_tax_formatted' => string '£15.00' (length=7)
          'weight' => int 0
          'sku' => string 'oct0003' (length=7)
          'title' => string 'Tote Bag' (length=8)
          'Product' => 
            object(PerchShop_Product)[17]
              ...
          'qty' => string '1' (length=1)
          'id' => string '3' (length=1)
  'shipping_id' => null
  'shipping_method' => null
  'shipping_tax' => string '0.00' (length=4)
  'shipping_tax_formatted' => string '£0.00' (length=6)
  'shipping_tax_rate' => int 0
  'shipping_with_tax' => string '0.00' (length=4)
  'shipping_with_tax_formatted' => string '£0.00' (length=6)
  'shipping_without_tax' => string '0.00' (length=4)
  'shipping_without_tax_formatted' => string '£0.00' (length=6)
  'total_items' => string '15.00' (length=5)
  'total_items_formatted' => string '£15.00' (length=7)
  'total_items_tax' => string '0.00' (length=4)
  'total_items_tax_formatted' => string '£0.00' (length=6)
  'total_shipping' => string '0.00' (length=4)
  'total_shipping_formatted' => string '£0.00' (length=6)
  'total_shipping_tax' => string '0.00' (length=4)
  'total_shipping_tax_formatted' => string '£0.00' (length=6)
  'total_items_with_shipping' => string '15.00' (length=5)
  'total_items_with_shipping_formatted' => string '£15.00' (length=7)
  'total_tax' => string '0.00' (length=4)
  'total_tax_formatted' => string '£0.00' (length=6)
  'total_items_discount' => string '0.00' (length=4)
  'total_items_discount_formatted' => string '£0.00' (length=6)
  'total_items_tax_discount' => string '0.00' (length=4)
  'total_items_tax_discount_formatted' => string '£0.00' (length=6)
  'total_items_discounted' => string '15.00' (length=5)
  'total_items_discounted_formatted' => string '£15.00' (length=7)
  'total_items_discounted_with_tax' => string '15.00' (length=5)
  'total_items_discounted_with_tax_formatted' => string '£15.00' (length=7)
  'total_shipping_discount' => string '0.00' (length=4)
  'total_shipping_discount_formatted' => string '£0.00' (length=6)
  'total_shipping_tax_discount' => string '0.00' (length=4)
  'total_shipping_tax_discount_formatted' => string '£0.00' (length=6)
  'total_tax_discount' => string '0.00' (length=4)
  'total_tax_discount_formatted' => string '£0.00' (length=6)
  'total_discounts' => string '0.00' (length=4)
  'total_discounts_formatted' => string '£0.00' (length=6)
  'total_discounts_with_tax' => string '0.00' (length=4)
  'total_discounts_with_tax_formatted' => string '£0.00' (length=6)
  'grand_total' => string '15.00' (length=5)
  'grand_total_formatted' => string '£15.00' (length=7)
  'shipping_weight' => string '0.00' (length=4)
  'tax_rate_totals' => 
    array (size=1)
      0 => 
        array (size=11)
          'exchange_rate' => string 'unknown' (length=7)
          'tax_rate' => string '0.00' (length=4)
          'tax_rate_formatted' => string '0 %' (length=3)
          'total_tax' => string '0.00' (length=4)
          'total_tax_formatted' => string '£0.00' (length=6)
          'total_value' => string '15.00' (length=5)
          'total_value_formatted' => string '£15.00' (length=7)
          'reporting_tax' => string '0.00' (length=4)
          'reporting_tax_formatted' => string '£0.00' (length=6)
          'reporting_value' => string '15.00' (length=5)
          'reporting_value_formatted' => string '£15.00' (length=7)
  'currency_id' => string '47' (length=2)
  'currency_code' => string 'GBP' (length=3)
  'currency_name' => string 'Pound sterling' (length=14)
  'currency_symbol' => string '£' (length=2)
Drew McLellan

Drew McLellan 2638 points
Perch Support

Hmm. I thought they were included at that point. If not, then I'm not sure what the next step is.

I've stepped through the perch_shop_checkout() function and that is getting the addresses from the database in addresses_are_set() in the shop runtime.