Created
April 6, 2020 11:00
-
-
Save iamsathyaseelan/a6f80c7bc2ed793915b621acb97d77ee to your computer and use it in GitHub Desktop.
getting free sample products
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('rnoc_get_cart_line_item_details', 'rnoc_get_cart_line_item_details', 10, 5); | |
function rnoc_get_cart_line_item_details($item_array, $cart, $item_key, $item, $item_details) | |
{ | |
if ($item_array['title'] == "Free Sample" && isset($item_details['free_sample']) && !empty($item_details['free_sample'])) { | |
$product = wc_get_product($item_details["free_sample"]); | |
$name = $item_array['title'] . " (" . $product->get_name() . ")"; | |
$item_array['title'] = $name; | |
} | |
return $item_array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment