• Hey there!

    I have a wordpress site that I am maintaining (Built on WP Bakery… I know) and work with a marketing agency.

    They want to pull some values for email marketing directly from the website, but can’t…

    On the page there are 3 prices:
    – including tax (this one they can pull)
    – excluding tax (they can’t pull)
    – “Staffel prijzen” (Translated: discount for bulk order) can’t pull

    The agency told me to add parameters to the values but I am clueless as to where to start… Any word of advice?

    • This topic was modified 2 years, 5 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Not 100% sure your end goal but you’re using woocommerce so you can maybe start with:

    <?php
    global $post;
    $args = array(
        'include' => array( $post->ID ),
    );
    $products = wc_get_products( $args );
    //print_r($products); /* see them all */
    
    $product = wc_get_products($post->ID);
    
    foreach ($product as $item_id => $item ) {
    	$item_data = $item->get_data();
    	echo $item_data['name'].'<br>';
    	echo $item_data['regular_price'].'<br>';
    	echo $item_data['sale_price'].'<br>';
    }	
    ?>

    if you put that in your footer.php it will display the woocommerce meta data for that current product. I don;t know how you have your three prices saved so you can always uncoomment the line //print_r($products); and see the full array to find the keys you need.

    Moderator bcworkz

    (@bcworkz)

    The answer depends on how they are “pulling” values. Using PHP prior to output is very different than using JavaScript or similar client side script.

    I’m guessing they are using something like JavaScript. In that case you could wrap the value they want in a <span> element and provide a unique id attribute the script can use to find the element in the DOM. Something like this:
    €<span id="prijzen-ex-1-4">37,95</span> Excl btw

    You can actually include custom data attributes like “data-prijzen” in HTML elements that script can directly access. But you still need a unique ID and such a custom attribute makes manual document maintenance more difficult because now any price change must be managed in two different places. It makes more sense when everything is managed automatically by code.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding parameters to text’ is closed to new replies.