GSoC’17 Coding period | Week #4 | Drupal

week4

 

The fourth week of Google Summer of Code 2017 has come to a close, bringing forth the onset of the First Evaluation Period. The conceptualization developed during the first phase of coding have been of immense help and has provided notable assistance for the completion of the assigned ports.

As I had stated in the previous blog posts, this month I had the objective of completing the following ports concerning the first phase of the coding regime:

  • Add Administrator wish list settings: This sub-module, to be brief had two functionalities to be considered for a successful port:

    • Configure wish list settings: These settings provide the admin with a substantial authority over any wishlist in general.

    • Manage user wishlists: Enables the admin to view/monitor and configure the user wishlists and also delete any wish list on getting expired or not required.

  • Include ‘Add to cart’ and ‘Add to wishlist’ buttons: This port would allow a user to add a preferred item to the shopping cart and/or any wishlist in general. This feature would also allow items in the cart to be added to a wishlist.

With the conclusion of week 4, I have completed the port of the administrator wish list settings as well as the ‘Add to wishlist’ feature as part of the second port. Thereby I would briefly like to state the steps taken to port the second functionality:

  • Include ‘Add to cart’ and ‘Add to wishlist’ buttons:

    • Considering adding items to cart, the function uc_cart_add_item() is be used. This button would be accessible on the user’s wish list only if product is not out of stock. To check that we would use uc_stock module uc_product_exist.

    • For adding items to a wish list, we would use the Hook function uc_wishlist_add_to_wishlist_submit and delivery to orders will add item to wish list and redirect the page.

    • Implement hook_form_validation to add validation to the uc_cart_view_form.

addwish

Moreover, for the ‘Add to Wishlist’ functionality to work successfully, my next objective would be to add the functionality to view/access the user wish list, on using the button. This functionality would further be succeeded by the option to update the specific wish list, by displaying the required button below the wish list.

So for carrying out the above port the following steps would have to be implemented:

  • Implementation of the Form & Module APIs, while the forms are created using $form=\Drupal::formBuilder()->getForm( ).

  • The callback: uc_wishlist_display($wid, $mode) is utilised under the function uc_wishlist_view_form to check for required permissions and private checkbox for lists:

    • Set $wid (wish list id) if it is null.

    • Check the if user is wish list owner and provide right to edit.

    • If the user is not the owner and there are no products, then show the link to search.

    • Display the required list if user is the owner or list is not private.

  • The Theme API is used to arrange the created forms in the resulting page.

View/Update functionality visuals:

view

Meanwhile, I have also figured out some crucial concepts regarding the subsequent ports and hope to complete the next earmarked ports before schedule for the second phase of the coding period. The code for the present status of the module can be found here.

Winding up, these were the objectives and concepts learned during the third week of coding phase in GSoC’17. Hope to learn many more new concepts in the coming weeks for the successful completion of the port.

Cheers!