Forum

Thread tagged as: Question, Members, Shop

Edit Shop address from Members Profile page

At the momnent, I understand the current limitations of the Shop / Members App, where if you want to save further information about a member, you need to do this outside of the shop/payment workflow.

As such, I have developed my profile template to expand on the allowed 'name, email' fields to include a series of questions.

This all works fine and to make the most of this 'member profile' page, I have also included the ability for the user to edit both their shop address and the password, thus making a single one stop page for members to control their profile.

However, I am having trouble with the editing and saving of the shop address. I realise that teh address is part of the shop, but I just cannot seem to work out how I can pass the members address ID into the code to return the correct address.

So, what do I have currently:

Profile.php

<?php 
   if (perch_member_logged_in()) {              
        perch_member_form('profile');
                perch_shop_edit_address_form(275); 
......

As I already know my addressID number for the member I have logged in form I, I can use this as a test to make sure the solution is working as it should.

Frustratingly, it cannot be combined with the 'save' of the complere member form, but at least the member gets another form and they can save the details.

However, how do I now make this generic.

 perch_shop_edit_address_form(perch_get('addressID')); 

will not work, so I am just trying to get an understanding of how I can pass in the addressID.

Is this possible ?

Thanks,

Andy

Andrew Kennedy

Andrew Kennedy 0 points

  • 3 years ago

Ok,

So after more coffee and some further digging and playing, it has resulted in the following.

By using:

perch_shop_customer_addresses();

in my profile.php file, will bring back the required address via the template: list.html

Within this is the link:

 <a href="/shop/addresses/<perch:shop id="addressID" />/">Edit</a>

What I worked out is that I needed to create a simple page template within the shop folder - address-edit.php

Within this, I could then use:

perch_shop_edit_address_form(perch_get('addressID'));

which will return an editable address.

Phew...

However, this has now taken the user away from the profile page and added in more steps, which is not ideal.

Maybe there is some way I can return the user to the profile.php page upon submit of the edit.html form, but ideally, I would much rather be able to integrate the edit.html tempalte within the profile.php page.

Whilst I have some form of working solution, it's not the best, so I am thinking there must be a way in which I can populate

perch_shop_edit_address_form();

with an addressID when called from profile.php, as if I manually populate it, it works, i.e.

perch_shop_edit_address_form(275);

Thanks,

Andy

Drew McLellan

Drew McLellan 2638 points
Perch Support

You can use the next attribute on a form to redirect to another page after the form has been completed.

<perch:form next="/profile.php">

Brilliant, thanks Drew, I will give that a go.