0

I'm using woocommerce and wordpress. I would like to know how to use a RewriteRule to change my url from: /my-account/edit-address/billing to /account/edit-address/billing and load the endpoint page content for billing address.

edit-address is a template file and loads content based on the endpoint billing or shipping

Is this possible

1 Answer 1

0

You should just need to change the permalink of the page in the back end of WordPress. You may also need to add the short code [woocommerce_my_account] to the page content depending on your version of WooCommerce. This would however also change the account page from my-account to just account aswell.

5
  • This is an external php that I'm building outside of WP - so no permalink :( All content loads ok except for this issue...
    – jmiller
    Commented Jan 25, 2016 at 10:21
  • Might want to include more information on this external script you;re writing in your question. From what I know the admin URLs have been made to be dynamic based on the setting in WooCommerces Account tab, however these options are all based off the root admin page currently selected so the permalinks for the "my-account" part are fixed based off that pages permalink. So you might need to spoof the page content by instantiating a new copy of WC_Shortcode_My_Account and calling the page manually with your own endpoint. Commented Jan 25, 2016 at 10:29
  • Thanks @Chris Morris. Actually, I have another question here: stackoverflow.com/questions/34918956/… with more details. The problem is I don't want to load the default my account page - because I'm building a tabbed version of it with each section under a tab. I have got this working. But the edit-address link points to a dead page and returns 404. Like you say, the content is loaded dynamically based on the endpoint. I would like to get the content for edit-address but load it on mys custom url /account/edit-address/
    – jmiller
    Commented Jan 25, 2016 at 10:51
  • Look at the edit_address function in WC_Shortcode_My_Account to see how WooCommerce brings this out and you should easily be able to bring out the content on your page, you might have to tweak how the form is submitted or add a redirect back to your custom account page to handle the form submission though. Commented Jan 25, 2016 at 10:58
  • Ok, here's the template for my account shortcod: github.com/woothemes/woocommerce/blob/… - edit address function on line 154. Also, here's the template for edit-address: github.com/woothemes/woocommerce/blob/master/templates/…. I've managed to link to edit-address but content fails at line 39. Both functions relate to foreach ( $address as $key => $field )
    – jmiller
    Commented Jan 26, 2016 at 9:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.