Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

197
Visualizações
How to duplicate a button and it's function to another predefined location

I am trying to duplicate my woocommerce add to cart button so it can be displayed a second time lower down my product page. However, I am using a plugin that alters the add to cart form (multiple option selections) and I need the new add to cart button to submit the options selected as well. I have the following javascript to duplicate the button i need:

( function( $ ) { 'use strict'; $(window).on( 'load', function() { var button = $( $.tcAPI().addToCartButtonSelector ).first(); button.tcClone().addClass( 'custom-add-to-cart-button' )
.on( 'click', function() {
button.trigger( 'click' );} ) .appendTo( $('.my-new-button') ); } ); }( window.jQuery ) );

But I am having issues creating a div with class= "my-new-button" to have appended and replaced with the functionality of the main button.

In the exact place I want the button to appear I have used:

<div class="my-new-button">
    <input type="button"  value="Add To Cart" />
</div> 

With no success of the JS appending the div.

If my script is even proper, how should I structure the div (or other) to display the button I want? I am by no means well versed so I appreciate any advice. Thank you

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda