Make theming the modal simpler and more configurable and other improvements.

Created on 29 December 2020, over 3 years ago
Updated 17 December 2023, 6 months ago

Problem/Motivation

There are several issues and patches in the queue that attempt to make theming the dialog popup simpler and more configurable.

I've spent the past few days combing through them and this module to come up with a forked version that I think is working pretty well and is easily customizable. So I am posting it here as a patch, in hopes that some or all of it makes its way into this module.

Proposed resolution

What I have attempted to do here is combine many of the concepts and approaches taken in the patches from the issue queue while adding a few of my own.

I realize this is a pretty big patch but it fixes a lot of the issues I was having applying patches that were either incomplete, outdated, and stepping on each other.

I've tried to comment everything I added and changed throughout to provide some of my reasoning for the changes. and help others understand what Is going on. (I know it took me some time to wrap my head around it)

Here's a summary of what's in the patch:

  • Updated the configuration form with several more options. And fixed a few places where the settings were not working or used incorrectly.
  • Added a theme template for the dialog, so developers can add whatever they would like in to the popup. hook_preprocess_ajax_add_to_cart_dialog() has an order_item variable available through which you can access the product added, cart, etc. and render whatever you would like.
    • Some ideas I was playing around with were ...
    • A view, using any of these as arguments (recently added, related products, etc)
    • A rendered view mode of the purchased product entity, or a summary of the order, etc.
    • Links to the checkout or cart
    • But pretty much anything you want to put in the popup can be done through here now.
  • Added a service for AjaxCartHelper and moved some of the procedural code into the class
  • Cleaned up some coding standards.
  • Fixed a bunch of bugs an inconsistencies I found with the ajax breaking under certain conditions.

All in all I think this is a huge improvement and hope others will try it out, and it doesn't just sit here for months or years. :) I am in the process of working on several projects where I will be using this and improving on what I have here.

I don't mean to step on anyone's toes who submitted the original patches. They were a great help to me putting this together. I just know from trying to apply some of them together that It was very difficult getting a working version of this. So hopefully this helps some people and can maybe make its way into the module.

This should apply cleanly to the latest dev 8.x-1.x-dev updated 24 Jul 2020

✨ Feature request
Status

Needs review

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States loze

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024