Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

149
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!