Blogs on

Drupal 7

knackforge blog

Drupal Commerce - PayPal payment was successful but order not completed

Most of us use PayPal as a payment gateway for our eCommerce sites. Zero upfront, No maintenance fee, API availability and documentation makes anyone easy to get started. At times online references offer out-dated documentation or doesn't apply to us due to account type (Business / Individual), Country of the account holder, etc. We had this tough time when we wanted to set up Auto return to Drupal website.

Continue reading →
knackforge blog

How to make Apache solr search programmatically from Drupal 7

Recently I came across a situation where I needed to make Apache solr search from drupal programmatically. Basically we have Apache solr module available in drupal, which enables to connect with solr for searching. There are loads of documentation for setting solr search with drupal, so instead going into those details, lets head straight to the custom code required to make programmatic solr search from drupal:

Continue reading →
knackforge blog

How to delete an order if the order is in cart for N days

In drupal commerce, the order will be created when a product is added to cart and the order will exist until the order is deleted or order status is changed to completed.

We have an e-commerce site in which most of the orders are idle in the shopping cart. So we decided to delete the order if the order is in the shopping cart for more than 'N' days or weeks. I have written a custom drush command for deleting the order.

The following code is used to delete an order if it is in the cart for more than 25 days.
 

Continue reading →
knackforge blog

Programmatically create and trigger feeds importer

We met with a challenging requirement where we needed to create a feeds importer on node creation of particular content type. It’s like for ‘n’ number of nodes there must be a ‘n’ number of feeds importer.

For that I created a feeds importer which will be considered as the template. Whenever the node of specific content type is created, the template will be cloned and a new importer will be created.

The following code needs to reside in hook_node_insert() and will be used to clone the feeds importer:

Continue reading →
knackforge blog

CDN Module, and Amazon Cloudfront in Drupal 7

Recently I decided to check out Amazon CloudFront to use it as a CDN. I felt delighted as it was so easy to setup with drupal and configuring it involving just a few steps. Another thing that excited me was its cost. It is really really cheap, just costs about 12 cents per gigabyte of transfer.

Step 1: Create a CloudFront Web Distribution

     To create a CloudFront web distribution

Continue reading →
knackforge blog

Drupal moodle integration

We got an interesting requirement, to integrate Drupal and Moodle (Totara actually) in order for a nice combination of CMS features and LMS features. The integration should follow SSO, where a user logged in Drupal should automatically be logged in Moodle.

We decided to use existing plugins as much as possible along with additional customization wherever needed.

Continue reading →
knackforge blog

Drupal Views exposed filter as Links

In Drupal views, we have the option of exposing the filters to users. By default, the exposed filters are displayed as Select boxes. Recently in a multilingual project, there was a requirement to display Courses based on Language. And the Languages had to be shown as links. In order to achieve this functionality, the Views exposed filter had to be customized.

To start with the customization, we need to alter "views_exposed_form" using hook_form_alter

Continue reading →