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

154
Visualizações
displaying a product attribute values as a variable

I have a script below where I automatically need to replace two values and I can't get it to work.

The values can be found as wooCommerce-product-attributes-item__label on the product page.

For instance, see the below.

Brand| "Ashley" MPN| "234gty"

I intend to pull the values of each attribute, "Ashley" and "234gty" and use them as variables to fill in the script below.

   var ccs_cc_args = ccs_cc_args || [];
   
   // Main Product Page
   ccs_cc_args.push(['cpn', '']);
   ccs_cc_args.push(['mf', '<p><?php echo $brand; ?></p>']);
   ccs_cc_args.push(['pn', '<p><?php echo $mpn; ?></p>']);
   ccs_cc_args.push(['upcean', 'UPC_EAN_CODE']);
   ccs_cc_args.push(['ccid', 'CATALOG_CODE']);
   ccs_cc_args.push(['lang', 'LANGUAGE']);
   ccs_cc_args.push(['market', 'MARKET']);
   
   (function () {
      var o = ccs_cc_args; o.push(['_SKey', '3f1b897a']); o.push(['_ZoneId', '6ce9a32538']);
      var sc = document.createElement('script'); sc.type = 'text/javascript'; sc.async = true;
      sc.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'cdn.cnetcontent.com/jsc/h.js';
      var n = document.getElementsByTagName('script')[0]; n.parentNode.insertBefore(sc, n);
   })();

I've tried adding the following to the footer.php and functions.php and echo to the product page with no luck.

global $product;

$mpn = array_shift( wc_get_product_terms( $product->id, 'pa_mpn', array( 'fields' => 'names' ) ) );

$brand = array_shift( wc_get_product_terms( $product->id, 'pa_brand', array( 'fields' => 'names' ) ) );

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