woo-address-book icon indicating copy to clipboard operation
woo-address-book copied to clipboard

WC Address Book

Open Data-Zombie opened this issue 1 year ago • 5 comments
trafficstars

Hello Matt,

Woocommerce endpoint for billing and shipping addresses is profile/addresses I did't like this structure and I would like to show some informations like Last 5 orders and shipping address on profile. With the help of elementor I have created the template but under address book I didn' find a way to retreve the second, third and so on addresses. There is any hook to show adress list on the profile page insted profile/addresses?

Just some screen that may help: profile (my template)--> https://ibb.co/rfXGgXY profile/addresses--> https://ibb.co/Jc3JFqx my goal--> https://ibb.co/2ZDhBtk

Can you assist me. I can buy a coffeeeee....!!!

Thanks

Data-Zombie avatar Jan 10 '24 20:01 Data-Zombie

Using WC_Address_Book->get_instance()->wc_address_book_page( 'billing' ); and WC_Address_Book->get_instance()->wc_address_book_page( 'shipping' ); calls will pull the address book templates into your page. You can override the templates in your theme if you like. That might get you started on the right path.

Or, you can get the address book data directly with WC_Address_Book->get_instance()->get_address_book( get_current_user_id(), 'billing' ) if you want to access the data directly to use how you want.

matt-h avatar Jan 11 '24 16:01 matt-h

Sorry for the late reply Matt, when you have time can you give me a snippet for WC_Address_Book->get_instance()->wc_address_book_page( 'shipping' ); and a snippet for WC_Address_Book->get_instance()->get_address_book( get_current_user_id(), 'shipping' ) ?? Thanks

Data-Zombie avatar Feb 10 '24 22:02 Data-Zombie

For the first, just whatever hook you have available to put it on your page

add_action( 'whatever-hook', function () { WC_Address_Book->get_instance()->wc_address_book_page( 'shipping' ) } );

So replace the name of the hook with what you have available.

WC_Address_Book->get_instance()->get_address_book( get_current_user_id(), 'shipping' ) just returns an array of address data. So you would use that if you are coding your own address page/layout and wanted to get the data to use in a custom way.

matt-h avatar Feb 13 '24 12:02 matt-h

I have some trouble with coding but I have a question: The list of shipping addresses are visible to the endpoint account -> addresses. Il possible to chenge the page where to show the list of shipping addresses from the plugin?

Data-Zombie avatar Feb 18 '24 23:02 Data-Zombie

Otherwise if I give you credentials for a staging site can you help me in exchange of a tip?

Data-Zombie avatar Feb 18 '24 23:02 Data-Zombie