doumei9589 2016-11-22 23:57
浏览 118

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.

  • 写回答

1条回答 默认 最新

  • dongyuqi3808 2016-11-23 04:27
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大