Adding SRP (custom plugin) field & Attribute (Warranty)
-
Hi everyone, (SRP is a custom MSRP code snippet that I managed to add the full set into functions.php — from Single Product page admin to Front view of the Single product)
I had used Code snippets in the past for SRP(shifted those into functions.php in the Child theme) to be included in Cart/Checkout’s Order Review — that works but it did not work for Order Emails.
So now I require to add Attribute (Warranty) in the same places.
I think I can use the same coding for the Attribute (Warranty), but am not sure about the coding for the Order Emails part. (But I need to know in place of “SRP” – what is the term of Attribute(Warranty) — is it pa_warranty?)Below is the Cart page – Product details currently.
Ideally the format of how these customised fields should be in the Order Review Table is as follows :
Format as follows :
Product name
(#SKU)
Attribute – Warranty
*
Quantity
POS Item No*
SRP
*denotes Ideally with a line space here
Currently I added SRP side — codings into functions.php — :/** SRP in Cart Table - Order Review **/ add_filter( 'woocommerce_cart_item_name', 'add_srp_after_item_name', 99, 3 ); function add_srp_after_item_name( $item_name, $cart_item, $cart_item_key ) { // The WC_Product object $product = $cart_item['data']; if (empty($product)) { return $item_name; } // Get the SRP $srp = $product->get_meta('_srp'); // When SRP doesn't exist if (empty($srp)) { return $item_name; } // Display the SRP $item_name .='<br><p style="color:darkblue; font-weight:600;" class="srp-price">'.__( "SRP : " . get_woocommerce_currency_symbol() . number_format( round($srp, 2), 2 ) ." / piece.","woocommerce"). '</p>'; return $item_name; } // number_format( round($srp, 2), 2 ) -- first rounded to two decimal, and displayed in 2 decimals.
I am open to use the Woocommerce Templates to change / add this as well. (For both SRP and Attribute (Warranty) — would that be simpler than code into functions.php?
Below is the Checkout page — Order Review table
Thank you.
Regards
ALLSTARS-FT
- The topic ‘Adding SRP (custom plugin) field & Attribute (Warranty)’ is closed to new replies.