I want to know how to add a custom form on the shipment page.

ramesh
ramesh engineer Posts: 6 πŸ§‘πŸ»β€πŸš€ - Cadet

Hey everyone, I'm new to Spryker and learning this amazing technology day by day. I want to add a new custom form on the shipment page and handle saving it to the database. Can anyone help me implement this?

Tagged:

Answers

  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,113 βš–οΈ - Guardians (admin)

    Heyhey @ramesh ,

    welcome to the Spryker world :D

    Have you already looked in our free developer trainings at safari.spryker.com? There you should find trainings for how to extend the profile form, how to persist data etc. That knowledge is the foundation of what you aim to do :)

    All the best,

    Florian

  • ramesh
    ramesh engineer Posts: 6 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited April 22

    Hey @fsmeier,

    Thank you for your quick response. I think extending the profile form is different from implementing a new form on the shipment page. Could you please share any other material or references?

    Regards,
    Ramesh

  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,113 βš–οΈ - Guardians (admin)

    Heyhey @ramesh ,

    yes, its different. Yet I think the beauty of Spryker is that it mostly follows the same procedures and structures.

    Lets do the thinking process together:

    1. "Shipment page" means for me its within the Checkout which is handled ootb by the StepEngine. The route for that is defined in the package checkout-page within vendor/spryker-shop/checkout-page/src/SprykerShop/Yves/CheckoutPage/Plugin/Router/CheckoutPageRouteProviderPlugin.php
    2. Based on that plugin within the method addShipmentStepRoute() you find out the correct controller and method (CheckoutController with the shipmentAction)
    3. So we open vendor/spryker-shop/checkout-page/src/SprykerShop/Yves/CheckoutPage/Controller/CheckoutController.php and find the method shipmentAction()
    4. You follow $this->getFactory()->createCheckoutFormFactory()->createShipmentFormCollection() and find the method in the file vendor/spryker-shop/checkout-page/src/SprykerShop/Yves/CheckoutPage/Form/FormFactory.php and you open the file
    5. You see that createShipmentFormCollection() uses getShipmentFormTypes() which in the end uses getShipmentCollectionForm() within the same file and you also find the form which is currently used for the shipment page: vendor/spryker-shop/checkout-page/src/SprykerShop/Yves/CheckoutPage/Form/Steps/ShipmentCollectionForm.php

    With the knowledge of the courses and finding these files and methods you should now be able to customize the shipment step :)

    Is my showed thought-process understandable? If anything is unclear dont hesitate to ask again and describe what you tried so far.

    All the best,

    Florian

  • ramesh
    ramesh engineer Posts: 6 πŸ§‘πŸ»β€πŸš€ - Cadet

    Yes, it's understandable….thank you for the detailed reply. But I'm still finding it difficult to implement this πŸ™‚

    I think customizing the checkout steps is a bit challenging... I might need a full course on this if possible πŸ˜„

  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,113 βš–οΈ - Guardians (admin)

    Yes, in the beginning it can be very overwhelming, but you will get there, soon!! πŸ’ͺ

    What you wanna achieve? Add fields to the shipping step? Add another step to request additional data from the customer?

    All the best,

    Florian

  • ramesh
    ramesh engineer Posts: 6 πŸ§‘πŸ»β€πŸš€ - Cadet

    In the shipping step itself, I want to add a custom "Delivery Instructions" form to collect data like:

    • Preferred Time Slot
    • Leave at Doorstep (checkbox)
    • Alternate Contact Number
    • Additional Instructions

    Is it possible? πŸ™‚