Skip to content

Add data-cart-item-key attribute to cart line item row. closes #63089.#63090

Merged
senadir merged 2 commits intowoocommerce:trunkfrom
helgatheviking:issues/63089-cart-item-row-data-key
Mar 7, 2026
Merged

Add data-cart-item-key attribute to cart line item row. closes #63089.#63090
senadir merged 2 commits intowoocommerce:trunkfrom
helgatheviking:issues/63089-cart-item-row-data-key

Conversation

@helgatheviking
Copy link
Copy Markdown
Contributor

@helgatheviking helgatheviking commented Feb 3, 2026

Changes proposed in this Pull Request:

Add data-cart-item-key attribute to cart line item row

<tr data-cart-item-key="7dfa3f6c45f6470f52154f9afce8d871" class="wc-block-cart-items__row" tabindex="-1"><td class="wc-block-cart-item__image"
...truncated/

Closes #63089 .

Screenshots or screen recordings:

image

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

  1. view source after cart block is rendered

Milestone

Note: Check the box above to have the milestone automatically assigned when merged.
Alternatively (e.g. for point releases), manually assign the appropriate milestone.

Changelog entry

  • Automatically create a changelog entry from the details below.
  • This Pull Request does not require a changelog entry. (Comment required below)
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Changelog Entry Comment

Comment

@github-actions github-actions Bot added type: community contribution plugin: woocommerce Issues related to the WooCommerce Core plugin. labels Feb 3, 2026
@woocommercebot woocommercebot requested review from a team, gigitux, jorgeatorres and senadir and removed request for a team February 3, 2026 16:06
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 3, 2026

Testing Guidelines

Hi ,

Apart from reviewing the code changes, please make sure to review the testing instructions (Guide) and verify that relevant tests (E2E, Unit, Integration, etc.) have been added or updated as needed.

Reminder: PR reviewers are required to document testing performed. This includes:

  • 🖼️ Screenshots or screen recordings.
  • 📝 List of functionality tested / steps followed.
  • 🌐 Site details (environment attributes such as hosting type, plugins, theme, store size, store age, and relevant settings).
  • 🔍 Any analysis performed, such as assessing potential impacts on environment attributes and other plugins, conducting performance profiling, or using LLM/AI-based analysis.

⚠️ Within the testing details you provide, please ensure that no sensitive information (such as API keys, passwords, user data, etc.) is included in this public issue.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 3, 2026

📝 Walkthrough

Walkthrough

These changes add a data-cart-item-key attribute to the cart line item row element, binding it to the lineItem.key value. A changelog entry documents this minor tweak to the cart line items table component.

Changes

Cohort / File(s) Summary
Changelog Entry
plugins/woocommerce/changelog/issues-63089-cart-item-row-data-key
Documents the addition of the data-cart-item-key attribute as a minor tweak.
Cart Line Item Row Component
plugins/woocommerce/client/blocks/assets/js/base/components/cart-checkout/cart-line-items-table/cart-line-item-row.tsx
Adds a data-cart-item-key attribute binding to the <tr> element, mapping it to lineItem.key for DOM identification purposes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the primary change: adding a data-cart-item-key attribute to cart line item row, with issue reference.
Linked Issues check ✅ Passed The PR implements the requested enhancement [#63089] to add a unique cart key data attribute to cart rows, meeting the stated objective of making cart rows identifiable and extensible.
Out of Scope Changes check ✅ Passed All changes are directly related to the linked objective: adding data-cart-item-key attribute and corresponding changelog entry, with no extraneous modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The pull request description clearly relates to the changeset, describing the addition of a data-cart-item-key attribute to cart line items with example code and screenshots.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@helgatheviking
Copy link
Copy Markdown
Contributor Author

I am working on using the iAPI to enhance something I want to display in the cart. however, the PR doesn't entirely fix the issue since the row is not present on page load... it is rendered later.

const { ref: button } = getElement();

const { item } = getContext();

if (!item?.key) {
	return;
}
			
setTimeout(() => {
	const row = document.querySelector(
		`.wc-block-cart-items__row[data-cart-item-key="${item.key}"]`
	);
	const prices = row?.querySelector('.wc-block-cart-item__prices');
	prices?.insertAdjacentHTML('beforeend', '<button>test</button>');
	}, 2000);

With a timeout this does work, but is there an event for when the cart is done rendering?

@jorgeatorres jorgeatorres removed their request for review February 27, 2026 15:56
@senadir senadir enabled auto-merge (squash) March 6, 2026 15:56
@senadir senadir merged commit 37f3113 into woocommerce:trunk Mar 7, 2026
72 of 74 checks passed
@github-actions github-actions Bot added this to the 10.7.0 milestone Mar 7, 2026
samnajian pushed a commit that referenced this pull request Mar 11, 2026
#63090)

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
jamesckemp pushed a commit that referenced this pull request Mar 11, 2026
#63090)

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugin: woocommerce Issues related to the WooCommerce Core plugin. type: community contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement]: Add unique cart key ID to the cart row render

2 participants