woo-commerce上每个产品的自定义按钮,包含唯一网址

I am trying to add a custom button “Buy On Ebay” displayed below the “BUY” now button on WooCommerce this should be included for every product loop linked to a custom field vendor_url in the back end so that I can specify each product with its own external link.

What I have tried so far.

1st effort

  • Installed advanced custom field plugin but I'm not sure how to hook the URL variable attributes to a button for each looping product. 50% Complete solution and would rather use the plugin below as vendor_url is the only custom variable needed.

2nd effort

  • Installed https://github.com/Ohar/wc-field-vendor-url This Plugin just adds custom field “vendor_url” to WooCommerce products. Which is exactly what I need however I don't know how to PHP include this variable attribute within a button.

Simplified

Front End: ‘Buy on Ebay’ button next to “Buy” button on Woocommerce.

Backend: vendor_url = 'Ebay Product URL'

Any help would be appreciated.

If you want to use advanced custom field plugin, use the plugin and create the field for the vendor_url in every product back end. Please check the documentation of the advanced custom field plugin for creating the new field.

The next step, to display the 'Buy on Ebay' button in product page front end, open the woocommerce folder ->templates ->single-product->add-to-cart. In add-to-cart folder you can see different templates for product type. If your product type is simple, open the simple.php and you can see the add to cart button code. Below this code you can create your 'Buy on Ebay' button.

<button type="submit" class="button alt">
<?php the_field('vendor_url'); ?></button> 

Note: use the key which used to create field for vendor_url.