How to add custom field and logic in Cart page?

This topic has 3 replies, 2 voices, and was last updated 2 years, 1 months ago ago by Radian

  • Avatar: craziestdavid
    Radian
    Participant
    September 27, 2022 at 19:42

    How to customize Xstore’s Cart page?

    I’d like to add some Field in Cart page. So users in cart page can select a date range and the page can refer to the day-count in the date range and recalculate its order price.

    And it is specific, I want to implement this function in “Cart Page” instead of “Checkout-Page”, so order can have a correct price before user checkout.

    How would you suggest me to do this? I searched some plugin, I don’t find one can match my need. So I think I need to go with custom PHP coding.

    Is there some php hook in Xstore? And is there a way to create my cart.php page to extend existing cart.php properly? Thanks!

    2 Answers
    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    September 28, 2022 at 07:32

    Hello,

    It is good to say we have lately implemented a few types of Advanced Cart/Checkout pages which you may check in Theme Options -> WooCommerce -> Cart/Checkout Layout.

    According to the fact you want to rewrite cart.php file you may do it in a next way:
    Go to Parent (XStore) theme -> WooCommerce folder
    -> cart -> cart.php (copy file) and paste it in the same path but in your child-theme (XStore-child theme -> WooCommerce folder
    -> cart -> cart.php (copied file)). In the file of your child theme you may edit it to your needs (if you do any changes in your child-theme it does not affect to theme updates and your changes will be in safe)

    WordPress docs: https://developer.wordpress.org/themes/advanced-topics/child-themes/

    All hooks and filters you may find directly in the file you want to use for improving. Example: https://prnt.sc/5Pae2LNutPG5 (cart.php)

    WordPress docs: https://developer.wordpress.org/plugins/hooks/

    As you know we don’t provide customization service but we can direct you in the right way of customization 🙂
    We found a topic where were asked a similar question as you want to have too -> https://wordpress.org/support/topic/creating-custom-field-on-cart-page/. We would recommend you check the answer and try to implement it on your side.

    It is asked in the WooCommerce plugin’s authors so you may also submit a topic on their forum.

    Regards

    Avatar: craziestdavid
    Radian
    Participant
    September 28, 2022 at 21:03

    So detailed reply! Thank you very much!

  • Viewing 3 results - 1 through 3 (of 3 total)

The issue related to '‘How to add custom field and logic in Cart page?’' has been successfully resolved, and the topic is now closed for further responses

8theme customization service
We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.