In Drupal Form API we can able to add prefix and suffix for fields. There are two types of adding prefix and suffix. a. Adding to Form Field b. Adding to Form elements
The function commerce_cart_order_load() help to load the current user cart details. Using the cart order object details we can able to unset or empty the commerce cart of that user. The function commerce_cart_order_empty() help to achieve this. The below sample code demonstrate how to delete cart of a user.
In Drupal commerce, cart items are handled as Entity. The cart items are referenced to the particular user id. Using user id we can able to load cart details that are currently added by the user. The function "commerce_cart_order_load()" takes user id as argument to load the cart details. The below example shows how to load cart details of the current user.
In Drupal while developing it not showing the errors instead of it will be showing us a White screen. This screen is known as White Screen Of Death(WSOD). During development, we need to debug the errors, for this purpose we want to show errors. To show errors instead or white screen we need to add below lines in "settings.php".
In programmatically we can able to alter commerce line items. The line items are kept as an entity in Drupal commerce system. Using the function "commerce_line_item_load()" we load line item as the object and able to access line item properties. The function commerce_line_item_save() will help to update the line item.
The below example shows how to redirect a user after login. This example code will not be affecting the password reset functionality of Drupal core.
In Drupal pager is act as page callback to list paged contents. To save page load we can change pager is Ajax pager. The Ajax pager helps to load next pager content instead of loading full page.
The function theme() will help to create pagination programmatically in Drupal. While passing the argument "pager" to a theme() with the additional parameter for construct pager will return the pager. The below syntax and example demonstrate how to implement pager in Drupal 7.
In Drupal we can able to create a Renderable table from array. This is achieved using function theme(). The theme function accepts Table header, row and attributes for table as associated array. The below syntax and example demonstrate build a table with Array.
The Commerce order will contain the information about the order that was placed. We can alter commerce order detail by loading this. With help of "field_attach_update()" function we can alter the commerce order details. The below is an example of commerce order update.