• I am developing an e-Commerce theme and got stuck on how to add an order page in the theme folder. Sorry if this question sounds silly to you. I am new to wordpress and this is my first project. I have done researches but couldn’t figure it out.

    I have successfully created customized post type and meta datas, now I have a “buy now” button on the product page to link to another php file in the same theme folder. This php file takes the product id and then calculate the price, redirects user to the payment page after checkout.

    But then I realized that the url would look ugly:
    https://www.example.com/wp-content/themes/mytheme/order.php?product_id=001

    I know I can place the php file in the wordpress root folder, but I am just curious: there are lots of e-Commerce themes, how did they handle this kind of situation?

Viewing 1 replies (of 1 total)
  • There’s a few ways of doing this that I can think of.

    1. Set up a template file for the cart, and set that template on the ‘Cart’ page.
    2. Set up a shortcode that displays the cart, and enter that shortcode on the ‘Cart’ page.
    3. Set up a content filter that replaces the page content with the cart when the page ID matches the ID of your ‘Cart’ page.

    Personally I’d use the first method, but there’s always other options if that doesn’t work for you.

Viewing 1 replies (of 1 total)
  • The topic ‘Add a new php file in the theme folder but don't want the url to be ugly’ is closed to new replies.