Centarro: Custom Order Number Patterns in Drupal Commerce

Drupal Commerce differentiates between the serial numeric ID assigned to an order by the database on save and the order number used to formally identify a placed order. Orders typically start as "drafts" (as in the case of shopping carts) and are assigned an order number when placed (as when a customer completes checkout).

In Commerce 1.x, the order number defaulted to the order ID. This created confusing order number sequences in admin listings when carts were checked out long after they were created or when they were abandoned. Businesses that required sequential order numbers without gaps needed custom code to make it happen.

Thanks to the Number Pattern module we added in Commerce 2.x, site builders have much greater control over order number generation via configuration alone. Number Pattern is used to generate order numbers and invoice numbers (via Commerce Invoice), and it is available for other contributed modules to use as well.

See selection here in the order type edit form:

Read more

Golems GABB: Layout builder toolset. Must have contrib modules for better layout control

Layout builder toolset. Must have contrib modules for better layout control Editor Tue, 01/24/2023 - 11:42

Dries Buytaert once wrote:

"...it can work with structured and unstructured content, and with templated and free-form pages."

One might call it primitive, but those who master it will be delighted with it because it is the basis. Hello friends! Today our focus is on Drupal Layout Builder. This is a nifty tool that all marketers and developers need.
Layout Builder is the best Drupal responsive web design tool for today. Drupal already has it at its core! That's awesome! Using Layout Builder in Drupal 8 or 9, you can add/remove sections to customize your pages following your requirements and display content using different layouts.

Matt Glaman: Leveraging the list cache tag for entity types

Recently I wrote about launching my wife's web store for her holiday cookie orders. During the launch, I had a little hiccup. The homepage controller has code to display the available published products. When it came time, I published the products, and... the homepage stayed the same. I was confused. I wrote the code and knew it was collecting cacheable metadata. It should have been updated once changes happened to the products. So, I did what all Drupalists do when things don't work as expected: clear the cache. Then I needed to figure out why this didn't work so that the homepage would be updated once we unpublished the products.

Specbee: How to create and apply a patch with Git Diff and Git Apply commands for your Drupal website

How to create and apply a patch with Git Diff and Git Apply commands for your Drupal website Akshay Devadiga 24 Jan, 2023 Subscribe to our Newsletter Now Subscribe Leave this field blank

Git has been a reliable version control tool for a large number of closed and open-source projects. With Drupal being an extremely collaborative open-source content management framework, a trackable, transparent, and distributed version control system like Git is a perfect fit. Git replaced a long-time version control partner – CVS – in early 2011 and became every Drupal developer and contributor’s favorite tool for its security, distributed nature, agile workflow, and of course, being open source!

If you’re a Drupal developer, you should be familiar with patches already. Patches are like band-aids. They are small pieces of code that are added on top of already existing code files to support it or fix any issues. Different types of patches include bug fixes, security vulnerability fixes, performance enhancements, styling fixes, etc. If you are a regular contributor to the Drupal project, you should know that to fix an issue in Drupal core or contributed modules, you must submit a patch to an issue in the issues queue. These patches are then examined and tested by the module maintainer and applied if found beneficial.

This is a revised version of the article. We’d like to thank Anktiha Shetty and Pratik Kadambari for all their great inputs! 

Image removed.


There are different ways to apply a Git patch. Let’s learn more about various Git Diff commands and how to create/apply a patch with the help of Git diff and Git apply. We will assume that you have already cloned/obtained a copy of the project in your local repository and have pulled the latest changes so you’re not working on an older version of the project. Take a look at some Github best practices here.

What does the Git Diff command do? 

Git diff is a command to output the changes between two sources inside the Git repository. The data sources can be two different branches, commits, files, etc.

The common use cases of git diff commands are listed below.

•    $ git diff 

This command will output all the modified changes which are not added to git or staged.

Image removed.


•    $ git diff filename

This will output the changes of that current file to its previous committed state.

Image removed.


•    $ git diff branch_name

This will output the modifications of the current branch to the mentioned branch to its previous committed state.

Image removed.


•    $ git diff --staged (or --cached) path/to/file

Once the changes are added to Git or moved to staging, you will not be able to see the diff of the files. To see the staged changes, you can use diff with --staged or --cached option.

Image removed.

 

•    $ git diff HEAD

To see the changes from both staged and unstaged changes (not untracked files) together, you can use the git diff HEAD command. If you have all changes staged for commit, then both commands i.e., --staged/–-cached and HEAD will output the same.

 

Image removed.

 

Image removed.

 

•    $ git diff commit_id1 commit_id2

To see the difference between any two commits you can use this git diff command where you need to mention the two commit ids.

Image removed.


If you want to see the list of commits made in the Git repo, use the command $ git log. This will list out all the commits (starting from the latest commit) along with their respective commit ids, the author (developer) and the date it was committed on.

Creating a Git patch with git diff

To create a Git patch, we can use any of the git diff commands to get the changes. We then need to save the changes to a file which can be used as below.
 

•    $ git diff > my_custom_patch_file.patch

 

Image removed.

 

Image removed.

 

Image removed.

Apply the Git Patch 

Drupal developers will want to apply Git patches frequently to update changes or to fix bugs. Developers will create a patch file that can be used by other developers according to their needs. To apply a git patch to the current branch use the following command.

•    $ git apply patch_file.patch 

 

Image removed.

 

Try the above command with the -v or --verbose option. It will cause additional information about the current patch being applied to be reported (as shown below).

 

Image removed.

Other useful Git patch apply conditions:

1. Working with trailing white spaces

Use --whitespace option to handle such situations.

Here the patch is created accidentally with trailing whitespaces (as shown below).

Image removed.

 

If the patch is applied as is: $git apply patch_file.patch
The patch will be applied (with whitespace warnings) and will still retain the whitespaces which can cause linting errors.

To fix trailing whitespaces while applying the patch, use the option --whitespace=fix, the patch will be applied, and trailing whitespaces will be removed.

Usage: $git apply --whitespace=fix patch_file.patch

2. Checking the patch before applying

To check before applying the patch, use option --check
The command will show no warnings and errors if the patch is applied cleanly.

Image removed.

 

Image removed.

 

3. To see file statistics before applying the patch

Use --stat option with the git apply command. It will list all files which will be changed upon applying the patch.

Image removed.

 

The patch will only show information, and will not be applied. 
To apply patch along with “stat” options add option --apply in command.

Usage: $git apply --stat --apply patch_file.patch

4. To apply only changes that are getting removed

Use Option --no-add with git apply.

For example:

Image removed.

 

Here only changes in red will be applied and green will be excluded.

Usage: $git apply --no-add patch_file.patch

 

Image removed.

 

5. Exclude and include the patch to be applied to selected files

Use --exclude option to exclude files from applying patch change.
    
$git apply --exclude=file_name.ext patch_file.patch 
    
Changes on other files, excluding mentioned file, will be reflected.

Vice versa: 

$git apply --include=file_name.ext patch_file.patch 

Changes only on the mentioned file will be reflected.

There might be a situation when the developer does not have write access to the project but still wants to suggest a change or fix a bug. The best way to go around that is to create a patch file. And because patches are additions to the code, testing and reviewing them is easy. This brief guide aims at helping Drupal developers get more familiar with git diff and git apply commands to be able to efficiently create and apply Git patches as needed. Contact us to know more about how we can help you with your next Drupal website.

Drupal Planet Drupal Tutorial Drupal Development Drupal

Leave us a Comment

 

Recent Blogs

Image Image removed.

How to create and apply a patch with Git Diff and Git Apply commands for your Drupal website

Image Image removed.

Installing Drupal 9 on Windows Subsystem for Linux from Scratch

Image Image removed.

How to Integrate Drupal 9 with Bitly for URL Shortening

Want to extract the maximum out of Drupal? TALK TO US

Featured Success Stories

Image removed.

Upgrading and consolidating multiple web properties to offer a coherent digital experience for Physicians Insurance

Image removed.

Upgrading the web presence of IEEE Information Theory Society, the most trusted voice for advanced technology

Image removed.

Great Southern Homes, one of the fastest growing home builders in the United States, sees greater results with Drupal 9

View all Case Studies

Talking Drupal: Talking Drupal #383 - Programming the Physical World

Today we are talking about Programming the Physical World with Stephen Cross.

For show notes visit: www.talkingDrupal.com/383

Topics
  • What is meant by Programming in the Physical World
  • How do people interact
  • How are we focusing today’s topic
  • What is a Microcontroller
  • What would you not use a microcontroller for
  • How do they get programmed and what language
  • How do you contain the device
  • Do you need to solder
  • How does this relate to Drupal
  • What have you used it for in the past
  • Where should I get started
Resources Hosts

Nic Laflin - www.nLighteneddevelopment.com @nicxvan John Picozzi - www.epam.com @johnpicozzi Stephen Cross - www.StephenCross.com @stephencross

MOTW Correspondent

Martin Anderson-Clutz - @mandclu Alexa Currently provides only a basic integration, for a developer to create a customized handler module to implement the specific functionality they need. An alexa_demo submodule provides a reference.

DrupalEasy: DrupalEasy Podcast S14E5 - Rod Martin - How to be a software trainer

We talk with Rod Martin about what it takes to be a software trainer (including informal, one-on-one teaching) and how students can best prepare for a training.

URLs mentioned

DrupalEasy News

Audio transcript

We're using the machine-driven Amazon Transcribe service to provide an audio transcript of this episode.

Subscribe

Subscribe to our podcast on iTunes, Google Play or Miro. Listen to our podcast on Stitcher.

If you'd like to leave us a voicemail, call 321-396-2340. Please keep in mind that we might play your voicemail during one of our future podcasts. Feel free to call in with suggestions, rants, questions, or corrections. If you'd rather just send us an email, please use our contact page.

Evolving Web: The 10 Best Non-Profit Websites of 2023

Image removed.

Reflecting on 2022, it was a busy and challenging year for non-profit organizations. Wars and grassroots protests captivated public attention. A mounting climate crisis continued to generate alarming headlines. Economic inflation threatened the industrialized world. This meant that would-be supporters had to seriously evaluate their bottom lines and time commitments more than ever.

Heading into 2023, it looks like another difficult year for charities and other non-profit organizations. The current global cost-of-living crisis shows no signs of slowing down. The ongoing war in Ukraine and the lingering effects of COVID-19 continue to cast a shadow. The need for strong non-profits has never been higher, from poverty relief to a global transition to green energy.

Unique Challenges for Charities 

In a sense, non-profits are not all that different from for-profit enterprises. Their supporters are just as valuable as customers are to a business. Non-profits, though, have an added challenge. While businesses sell tangible products and services that the customer can interact with, charities are selling intangibles or tangibles given to someone else in need. It’s harder to sell an altruistic feeling than the latest cell phone.

Now, non-profits need to be even more clever and nimble with limited resources. A recent article in Charity Village asserts that in the current social and economic climate, successful non-profits will be the ones championing flexible giving options (e.g. online giving) while maximizing donor and volunteer retention, ensuring stable revenue through recurring (e.g. monthly) giving programs.

Among the statistics the article cites are:

  • Nearly half of donors over the age of 60 now give online
  • Nonprofit text messaging audiences grew by 26%
  • 60% of millennials show interest in monthly online giving; 45% have already done so
  • Roughly 70% of donors only give to an organization once, which means a net loss to non-profits bearing to the cost of donor acquisition

The successful non-profit in 2023 will be able to through the noise, communicate its message clearly and enable donors and volunteers to donate or participate hassle-free. 

What Makes an Outstanding Non-profit Site?

Would-be supporters want to know that their time and money is making a real impact. Non-profit websites have a high-stakes job to demonstrate that impact and make it easy to navigate, donate and volunteer. 

Our top 10 sites are an eclectic mix, each a leader in their own field.

What unites them

  • A strong, unifying brand identity
  • Effective use of storytelling
  • Clear explanations of how the organizations function and make their impact
  • Hope over doom-and-gloom
  • Clear calls-to-action (CTA’s) throughout, with multiple and easy-to-click access through which to contribute money and/or time
  • Strong multi-channel approaches with multiple social media platforms
  • Personal touches, like photographs and stories 
Image Image removed.

1. Only One

It’s easy to feel disoriented and powerless when it comes to the world’s innumerable overlapping environmental and climate crises. The science behind it is hard to grasp, the headlines are usually apocalyptic and the forces at work can seem too formidable for any one person to make a meaningful difference.

Only One is an outlier in this space. Founded in 2019 by Sea Legacy and the Blue Sphere Foundation, this site aims to amplify stories that inspire action to protect the ocean, the planet and those disproportionately affected by climate change. It invites site visitors to choose from a range of bite-sized but meaningful donation plans to improve the health of the world’s oceans and environment as a whole, from planting coral and trees to removing plastic and reducing carbon.

Standout features:

  • Friendly, illustrative, modern and professional design
  • Compelling use of photos - its founders are renowned nature photographers
  • Positive storytelling, no doom-and-gloom messaging
  • Easy-to-sign petitions with forms that remember your name to make signing easier
  • A subscription-based donation page that enables donors to select a cause meaningful to them at an appropriate level of financial commitment

Only One is also a great example of a multichannel strategy in action. They have a powerful Instagram presence, and supporters are able to sign petitions via social media. 

 

Image Image removed.

2. Charity: Water

Charity: Water is an organization bringing clean, safe water to people around the world. Founded in 2006, the organization currently operates in 29 countries and has funded 111,796 water projects (as of December 2022), directly impacting the lives of over 15 million people – primarily in South Asia and Sub-Saharan Africa. It works with local organizations to implement projects as well as monitor and maintain them, ensuring long-term sustainability.

Charity: Water demonstrates textbook examples of the many of the elements that go into a good nonprofit website: consistent branding, clear calls-to-action, visible links, clear messaging around its mission and a hopeful tone.

Standout features: 

  • Beautiful design featuring beautiful regional and human-centred photography 
  • Engaging storytelling highlighting beneficiaries’ voices
  • Superb copywriting with strong, active language and straightforward messaging
  • A user-friendly donation module on the homepage, enabling both one-time and monthly donations, up to and including sponsoring an entire water project

Charity: Water is also active on social media, with a particularly engaging YouTube channel. It features footage of water projects in action and interviews with organization leaders and members.

 

Image Image removed.

3. Girls Who Code

Girls Who Code aims to close the gender gap in computer technology. By providing programs for girls to learn about technology and programming, they see it as a viable career option. Through in-person programming, including a summer immersion program, clubs and college loops, GWC has empowered over 500,000 girls with the skills to pursue education and careers in computing.

GWC’s website is impactful and engaging. It lets the user self-select so they get the most-needed information. Students can input their grade and location, and immediately see nearby programs. The site uses engaging infographics to demonstrate the need for their programs and its impact on students and organizes the information clearly.

Standout features:

  • A clear mission statement displayed from the get-go 
  • Clean and simple logo design with an inviting, friendly colour palette
  • Beautiful, positive, people-focused imagery featuring BIPOC 
  • Simple and clear UX
  • Clean and clever icon designs
  • Prominent donate and “get updates” buttons 
  • Compelling testimonials

Also well worth mentioning is the related (and also excellent) site Black Girls Code, which focuses specifically on empowering young women of colour to pursue computer programming.

 

Image Image removed.

4. War in Ukraine (war.artmilitonian.com)

Russia’s wholesale invasion of Ukraine in February 2022 was the defining news story of the year. And it looks to continue in 2023, with a staggering number of non-profit websites springing up to support Ukraine.

While there are numerous organizations offering military and humanitarian aid that are worth supporting, one website truly stands out from the pack: Artem Militonian’s award-winning site War in Ukraine. Created by an expatriate Armenian-born Russian designer, War in Ukraine is an immersive web experience that takes you through the chronology of the Russian invasion, with handy links to organizations to support.

Standout features:

  • Captivating design with a foreboding atmosphere designed to conjure the feeling of war
  • Simple design – simply click on the site and scroll down for the timeline of the war
  • Use of all-caps throughout the site, creating a sense of urgency
  • Visually dramatic, with use of photography sourced from news agencies
  • The long scroll format of the website feels neverending, evocative of the war itself

Also well worth checking out is Artem Militonian’s breathtaking website commemorating the Armenian Genocide, which follows a similar format. Like the War in Ukraine site, it’s not for the faint of heart.

 

Image Image removed.

5. SickKids

The Hospital for Sick Children (HSC), – operating under the corporate brand ‘SickKids’ – is a major pediatric teaching hospital affiliated with the University of Toronto. A major global hub for research in pediatrics, the hospital was ranked the top pediatric hospital in the world by Newsweek in 2021.

The SickKids website embodies all the best practices you would expect from the web platform of a world-leading medical institution. While the site itself is very large, it is organized in a way that is approachable and non-threatening. With loved ones of sick children in mind, site visitors are invited to search what they’re looking for in a friendly search module labeled “How can we help you today?” There’s also direct access to Virtual Urgent Care, a COVID-19 Info Hub, Coming to SickKids and an invitation to donate.

Standout features:

  • Simple, calming colour palette accentuated by use of round corners
  • Background textural elements that create a sense of movement and calmness
  • Imagery that focuses on hope and optimism
  • Prominent "Support Kids" button, which creates a focal point
  • A prominent emergency button that allows users to get care more quickly

The site also has a sister site, SickKids Foundation, a marketing-driven site for donors and potential sponsors. This site is also visually impactful, with a navigation that has three primary calls-to-action: donate, shop and fundraise.

Image Image removed.

6. Right To Play

Right To Play is a Toronto-based international organization. Its mission is to use play to empower vulnerable children to overcome the effects of war, poverty and disease. Operating in 15 countries worldwide, the organization focuses on four major outcome areas: quality education, children's health and well-being, girls' empowerment and child protection.

The Right To Play website is strongly branded and unique to the organization, with its mission statement highlighted front-and-centre on the homepage. With vivid, uplifting photographs of culturally diverse children at play throughout the site, its atmosphere is positively upbeat. The navigation is intuitive, offering multiple access points for people to donate or otherwise support the organization.

Standout features:

  • Simple brand colour palette and curated photos, giving it a cohesive feel
  • Effective split between primary and secondary navigation
  • Use of hand-written font makes it feel more personal 
  • Positioning donation as a focal point
  • Beautifully curated videos that create impact
  • Effective use of storytelling, pulling users into the content
  • Just enough facts to be informative and not overwhelming

Right to Play also maintains a multi-channel social media presence, with a particularly engaging presence on YouTube and Instagram

 

Image Image removed.

7. Mira

Mira is the brainchild of Éric St-Pierre, a dog trainer from Sainte-Madeleine, Québec. Founded in 1981, Mira was the first francophone centre for Guide Dogs in Canada. Today, Mira offers free guide dogs and service dogs to people living with visual impairments and physical disabilities and to youth with Autism Spectrum Disorder (ASD).

Mira’s fully bilingual website is a textbook example of simple, accessible and engaging design. A video on the homepage helps engage users right from the start, while the page directs visitors to the organization’s three focal areas: guide dogs for the visually impaired, service dogs for people with mobility issues and dogs for children with ASD. It also features an in-depth look at the typical life of a dog involved in the program.

Standout features:

  • Clean, simple design with a minimal colour palette that keeps things digestible
  • Straightforward navigation structure with large logo for added emphasis
  • Strong storytelling elements with particular appeal to dog-lovers 
  • Intriguing illustrations that lead the user into the content – illustrations play with figure/ground ambiguity (superimposed dog/human images) 
  • Excellent copywriting in both French and English
  • A prominent ‘donate’ button

The site also houses an online retail store that sells branded Mira products, ranging from dog calendars and Christmas cards to dog owner supplies and apparel.

 

Image Image removed.

8. World Bicycle Relief

The bicycle is a well-demonstrated instrument of poverty reduction. Statistics show that a bicycle can increase the income of a family living in poverty by as much as 35%. The Chicago-based non-profit World Bicycle Relief works to do just that. Founded in 2005, WBR has distributed more than 500,000 bicycles in 21 countries and trained more than 2,300 bicycle mechanics in the developing world.

Worldbicyclerelief.org is a striking website with some remarkable design features. Above all, it’s a storytelling engine that seeks to share the true stories of the impact of bicycles. Featuring videos, stories and quotes from people whose lives have been changed by bicycles, the site introduces us to the issues through a human lens and makes a clear case for how the potential donor could participate. 

Standout features:

  • Video content that pulls users into the content
  • Parallax animations that create a smooth experience from section to section on the homepage
  • Subtle animations and clever multiple meaning messaging
  • Modern, clean colour palette
  • Fact-focused copy with an emphasis on statistics that demonstrate the program’s impact
  • Mission statement shown right at the beginning

WBR is another great example of a multi-channel approach, with supporters able to engage and donate via social media.

 

Image Image removed.

9. Canadian Blood Services

Giving blood is one of those things that most people agree is important but many of us don’t do. A recent poll showed that while six in ten eligible donors in Canada believed donating blood or plasma was important, only one in ten had plans to donate. Canadian Blood Services works to reduce this reluctance to donate blood and seeks to address the growing shortfalls in national supply of plasma and stem cells.

Canadian Blood Services’ website (blood.ca) is invariably the first thing that shows up in a Google search in Canada for the word “blood”, and is the country’s go-to online hub for all things blood-related (except in Québec, which is served provincially by Héma-Québec). 

It’s an enormous site with a vast amount of information, yet it somehow manages to be accessible and approachable – a great asset when it comes to topics that many people find threatening or uncomfortable.

Standout features:

  • Multiple points of access into the site’s vast informational resources
  • Prominent feature stories of people whose lives have been impacted by blood, plasma, stem cell or organ donation
  • Clear calls-to-action on virtually every page
  • Consistent and appealing branding centred on two colours: red representing blood and plasma and blue-green representing stem cells and organ and tissue
  • Multiple “ways to donate” buttons throughout the site

In addition to encouraging blood donations, the site also enables people to support the organization in other ways, including through a retail store that sells branded apparel and stationery supplies.

 

Image Image removed.

10. Million Peacemakers

Million Peacemakers is an organization close to our heart here at Evolving Web – both for its activism and the client relationship it shares with us. Founded in Montreal, this award-winning organization has trained over 225,000 people in 23 countries since its five-year inception with a patented three-step conflict resolution methodology called Nonflict.

The current Million Peacemakers’ website does a superb job of introducing visitors to the threats of conflict on businesses, nations, families and youth. The homepage centres on an introductory video, which effectively sets the tone of the site, and leads directly to an explanation of Nonflict, the site’s main topic. The homepage offers multiple access points for people to connect with and support the organization.

Evolving Web is currently in the process of revamping Million Peacemaker’s web presence, starting with a subsite for Million Peacemakers Youth – geared for one of the organization’s key volunteer bases. The new subsite aims to cast the visiting youth as a “superhero” capable of making a world of difference. As you continue down the page, calls-to-action will prompt the user to rise to the challenge, while a continuous line graphic throughout the site will represent connection and the work-in-progress nature of activism.

The new site will feature:

  • Flexible, scalable, easy-to-use Wix platform
  • Brief, direct, action-oriented, youth-focused and wireframe-friendly web copy
  • The concept of Nonflict kept front-and-centre in depictions of what volunteering for MP looks like
  • Warm accent colours to draw attention to important elements like CTAs
  • Extensive photos, especially of youths in action working together

Let’s Join Forces

We have a heart for non-profits at Evolving Web. If you’re part of an organization seeking to improve your web presence, we would love to hear from you. Contact us today and get us to work helping you make a bigger impact.

+ more awesome articles by Evolving Web