I have created Custom Button using following Code at themes/package/woocommerce/single-product/add-to-cart/simple.php

    if($_product->getCustom_button()){ //yes or no button
    <button type="button" title="<?php echo $_product->getCustom_button_name() ;?>" class="btn btn-default" onclick="window.open('<?php echo $_product->getCustom_button_url() ;?>')"><span><span><i class="icon-desktop"></i><?php echo $_product->getCustom_button_name() ;?></span></span></button>
<?php } ?>

but this code is not work properly. i want custom button work with product attributes. enter image description here

  • Please explain yourself little-bit more, share what is your intention to do and what issue you are facing right now.
    – mlimon
    Commented Oct 12, 2017 at 10:48
  • when i have add above mention code simple.php show my page is blank and product image, footer and addtocard button and custom not showing an Commented Oct 12, 2017 at 10:53
  • What is $_product, what does getCustom_button() do? Commented Oct 12, 2017 at 11:58
  • i have use same code in magento site this code work perfectly and custom_button is attribute id Commented Oct 13, 2017 at 17:14

2 Answers 2

function cmk_additional_button() {
    echo '<button type="submit" class="button alt">Change me please</button>';

add this code in your Child theme functions.php

Try this code


You can use this code to add anything like button, text using this below code

function my_custom_content(){
    // get_the_ID() is product ID
    // echo anything you want
add_action( 'woocommerce_after_add_to_cart_button', 'my_custom_content' );
  • this code is not work Commented Oct 12, 2017 at 11:24
  • May be you did not use it in correct way, this is the best solution to add custom content like button on the section you are looking for Commented Oct 12, 2017 at 14:54
  • i want custom button in singal product page and i have past your code at themes/package/woocommerce/single-product/add-to-cart/simple.php Commented Oct 13, 2017 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.