Amateur with programming (and love it), long time reader and first time poster.

I have set up a Woocommerce cart here at http://centrowireless.com/inventory/. I have a Contact for Price button made with the WP Call for Price plugin. I have made some customizations by changing the text to "Contact for Price", adding a div for some CSS and adding a mailto when the button is clicked:

public function empty_price($price) { return '<div class="contactproduct"><a href="mailto:offers@centrowireless.com">Contact for Price</a></div>'; }

My question is, how can I auto populate the subject of that email so that the subject is the specific product the clicked button is a part of?

Thank you,

Evan

有帮助吗?

解决方案

This code is working for me, please give it a try:

public function empty_price($price) {
    global $post;
    return '<div class="contactproduct"><a href="mailto:offers@centrowireless.com?subject='.urlencode($post->post_title).'">Contact for Price</a></div>';
}

其他提示

I'd imagine that simply

<?php the_title(); ?>

would work just fine. Here's an example:

<a href="mailto:my@email.com?subject=<?php the_title(); ?>">Contact for Price</a>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top