-2

I have code to create a review email, using the product the customer ordered, a photo of it and a link to the review part of the product page. The code looks like this -

<tbody>
<?php $items = $order->get_items();
    foreach ($items as $item) {
        $product = new WC_Product($item['product_id']);
        ?>
        <tr>
            <td nowrap><?php echo $product->get_image($size = 'shop_thumbnail'); ?></td>
            <td nowrap><?php echo $product->get_title(); ?> </td>
            <td nowrap><a href="<?php echo $url = get_permalink($product->id).'#reviews'; ?>" style="background-color: #000; color: #fff; text-decoration: none; padding: 10px;">REVIEW NOW</a></td>
        </tr>
<?php                                                                   }
?>
</tbody>

I want to change the link on the 'review now' box to be a static link. I've tried the below but it doesn't work.

<a href="<?php echo $url = "www.google.com" ?>" style="background-color: #000; color: #fff; text-decoration: none; padding: 10px;">REVIEW NOW</a>
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
Michelle
  • 549
  • 1
  • 5
  • 25
  • 2
    The *href* attribute of the link should be a valid URL so `www.google.com` has to be replaced by `https://www.google.com` or whatever. You need to add the protocol. If it's static then no PHP tags are needed to create it so just put ` – Patrick Janser Feb 18 '22 at 09:45

1 Answers1

0

No need to use php for static url. You can add it directly in href attribute of anchor tag. <a href="https://www.google.com/" style="background-color: #000; color: #fff; text-decoration: none; padding: 10px;">REVIEW NOW</a>

zareen
  • 1
  • 1