Wrap product name with <span> and selectable "class" in checkout-review-order-table and email-order-items
#29,386 opened on 2021/03/15
Repository metrics
- Stars
- (10,294 個のスター)
- PR merge metrics
- (平均マージ 9d 12h) (30d で 423 merged PRs)
説明
Is your feature request related to a problem? Please describe.
All our product names are set in UPPERCASE using CSS with text-transform: uppercase;. This works great except for the overview table on the checkout page, see
and also not for the order items table in mails
see
The quantity is wrapped in a strong with class="product-quantity". However, the product name itself is not and hence it is not possible to select the product name here with CSS.
Describe the solution you'd like
Please simply wrap the product name with a CSS class, e.g. `The product name. Then it would be easy to make this uppercase with some little custom CSS like
.wc-cart-product-name {
text-transform: uppercase;
}
Describe alternatives you've considered
I had a look into the filter like woocommerce_cart_item_name, e.g.:
// Display product name as uppercase, CSS is not possible
// Too dangerous, because sometimes the $product_name can come as a link as sprintf( '<a href="%s">%s</a>' ...)
function fr_uppercase_product_name_in_cart( $product_name, $cart_item, $cart_item_key ) {
return strtoupper( $product_name );
}
add_filter( 'woocommerce_cart_item_name' , 'fr_uppercase_product_name_in_cart', 10, 3 );
However, this seems dangerous because sometimes the $product_name parameter is not a simple string but some HTML markup, e.g. at
Same holds true for the filter named woocommerce_order_item_name as used in emails at
but also as HTML markup at
and
The second alternative of overriding the template files just for this seems a problematic regaring future upgrades.
Additional context
Initially, we asked about this in this WooCommerce Germanized forum thread which lead to the conclusion that nothing can be done here by the Germanized plugin unless the CSS name is added in WooCommerce itself.
https://wordpress.org/support/topic/eine-css-klasse-um-produktname-auf-kasse-seite/
Translated version: https://translate.google.com/translate?hl=&sl=de&tl=en&u=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Feine-css-klasse-um-produktname-auf-kasse-seite%2F