This forum is for module development and code related questions, not general module support. For general support, use the post installation forum.

E commerce functionality Advice.

Hello Friends,

I have been tasked with adding eccomerce functionality to my Drupal 8 site.

Currently I am looking at the Commerce 2.x module to help me with achieving this. 

The problem I am currently facing is that I am required to store and query all content in a custom database and the Commerce 2.x module looks like it relies heavily on Drupals native database.

Some solutions I am considering are:

How do I display a pdf from a controller?

In Drupal 7 I did this in my page callback:

function ops_view_pdf() {
	$filepath = $_GET['file'];
	drupal_add_http_header('Cache-Control', 'private');
	drupal_add_http_header('Content-Type', 'application/pdf');
	return NULL;

How do I do this in Drupal 8?

Error in extracting zip files

I am facing an error in extracting audio files uploaded in zip format. The error is as follows- Argument 2 passed to Drupal\Core\Archiver\Zip::extract() must be of the type array, string given,  

The following is the code:

public function buildForm(array $form, FormStateInterface $form_state, $node = NULL) {


hook_boot in D8 using Event Subscriber

Hi All,

I want to execute an ajax request on page load in D8. (intention to execute some process on page load which I have done using hook_boot in D7, Now I am trying to achieve in Drupal 8.7.6)

I have used event subscriber (refered I have added mymodule.libraries.yml file where I have mentioned about JS file, I have included JS file via hook_preprocess hook in mymodule.module file. 

Redirect user when batch ajax encounters an error

I have a batch and when the operation is running and encountered

"An AJAX HTTP error occurred."

I want to redirect the user to another page and display the errors nicely. How can I do that with D8 batch? 

Thanks in advance!

Clearing the cart before adding the product. Drupal 8 + Commerce 2

I am using Drupal8, Commerce 2, Commerce Recurring and Commerce Licence. 

I am selling yearly subscription.

Issue and Steps

  • User can add subscription product into cart
  • User redirecting to cart page
  • User hits back button and visit product page(subscription page) again.
  • User again add subscription product into cart. 
  • Then user end up with 2 same subscription products into cart. Need to restrict user to add multiple product into cart.

Possible solution:


Subscribe with RSS Subscribe to RSS - Module Development and Code Questions