Blogz

Recent Blogz

Drupal 7: Programatically Delete a Commerece order

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.

Drupal 7: Programatically Loading commerece cart item of a user with samplecode

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.

Drupal: Show Erros on Developing or WSOD

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".

Drupal 7: Programatically update commerec Line Item with example

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.

Drupal 7: Programatically Create Pagination with Example

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.

Drupal 7 : Programatically Render Table - theme() Example

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.
Sl NoNameCountry
1MohanIndia
2DineshRussia
3SwathyAmerica
4GayathriEngland

Drupal 8: Enabling/Disabling Theme Debugging

Theme debugging will help on developing our Drupal 8 site. It will suggest the TWIG file that associate for DOM structure to change. This information is appended to command in HTML that Drupal renders. We can access this information in inspecting the HTML or on developer window. When debugging is enabled the markup of each Twig template is surrounded by HTML comments that, contain theming information, such as template file name suggestions.