Skip to content

Instantly share code, notes, and snippets.

@iamsathyaseelan
Created April 6, 2020 11:00
Show Gist options
  • Save iamsathyaseelan/a6f80c7bc2ed793915b621acb97d77ee to your computer and use it in GitHub Desktop.
Save iamsathyaseelan/a6f80c7bc2ed793915b621acb97d77ee to your computer and use it in GitHub Desktop.
getting free sample products
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