This is the code to get the description of your products in the cart. See attached for how it looks on my website.
Thanks Morgan for sharing. Good approach!
Is there anyway that inserting this code into the theme's function php file could crash my website, or are the two events entirely unrelated...?
Fantastic! Thank you life-saver!!!
Any updates with this after 7 months? I couldn't get this working
Got this working. My problem is that it shows all the elements from the canvas. in my shopping cart. How can I change it that it only shows selected variation?
@Mark I have a solution to limit the output and also a bonus to swap out the hex vals for color names. First to limit what elements are shown simply add an if statement to the last block. Like so:
//add the name and value pair to the detail array if($fpd_detail_name == 'T-Shirt') { $other_data[] = array( 'name' => $fpd_detail_name, 'value' => $fpd_detail_value ); }
You'l want to pay attention to the part:
if($fpd_detail_name == 'T-Shirt') {
You can change "T-Shirt" to whatever you want to KEEP. Or you could use a != and EXCLUDE "T-Shirt" and keep everything else. I suppose you could build a switch if you'd like to keep more than one thing but I'm sure you can see what's happening here.
Bonus: Here is some code you can use to switch out the hex vals for color names. Add this to the block just above the last one:
//the currentColor value is set inside yet another array if(is_array($value)){ foreach($value as $val_key => $val_val){ if( $val_key == 'currentColor' && !empty($val_val) ){ $fpd_detail_value = $val_val; // *** Swap out Hex for Color Names *** switch ($fpd_detail_value) { case "#000000": $fpd_detail_value = "Black"; break; case "#ffffff": $fpd_detail_value = "White"; break; case "#ff0000": $fpd_detail_value = "Red"; break; case "#cccccc": $fpd_detail_value = "Heather"; break; case "#ffff00": $fpd_detail_value = "Yellow"; break; case "#003366": $fpd_detail_value = "Navy"; break; case "#33cc33": $fpd_detail_value = "Green"; break; } } }
The custom parts are after "*** Swap out Hex for Color Names ***". Here we are just checking and resetting the final var to what we want.
Hope this helps some peeps ;)
-RJB
Morgan Creech
Just a bit of code that might be helpful to someone else.
The following goes in your theme's function php file: