Skip to content

Instantly share code, notes, and snippets.

@racmanuel
Last active September 20, 2021 13:16
Show Gist options
  • Save racmanuel/e7b63a3edc304387d5be8fe54cd1c240 to your computer and use it in GitHub Desktop.
Save racmanuel/e7b63a3edc304387d5be8fe54cd1c240 to your computer and use it in GitHub Desktop.
Add a Button on product pages if is in a category - Wocommerce
<?php
/** Add "Have one to sell?" Button on product pages */
function wc_button_have_one_to_sell()
{
if (has_term('marketplace', 'product_cat')) {
?>
<!-- Here your HTML -->
<div class="card" id="card-have-one-to-sell">
<h4 class="card-heading">
<i class="card-icon icon-cash-dollar"></i>
Have one to Sell?
</h4>
<hr class="card-hr">
<div class="card-body">
<a class="btn btn-have-one-to-sell" id="btn-have-one-to-sell"
href="<?php echo get_home_url() . '/vendors-dashboard' ?>">Click to sell the product</a>
</div>
</div>
<?php
}
}
add_action('woocommerce_after_single_product_summary', 'wc_button_have_one_to_sell');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment