{"id":264,"date":"2024-02-13T12:54:13","date_gmt":"2024-02-13T12:54:13","guid":{"rendered":"https:\/\/daniwp.com\/?p=264"},"modified":"2024-02-13T12:54:13","modified_gmt":"2024-02-13T12:54:13","slug":"how-to-replace-woocommerce-external-affiliate-button-text-using-mysql","status":"publish","type":"post","link":"https:\/\/wproduct.io\/?p=264","title":{"rendered":"How to Replace WooCommerce External \/ Affiliate Product Button Text Using MySQL"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">There&#8217;s an easy way to replace the default WooCommerce <em>Buy product<\/em> button text on the <em>External \/ Affiliate products<\/em> by editing the <em>functions.php<\/em> file of your WordPress theme. But, here I show how to change the button text using MySQL.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The MySQL method is helpful if you want to keep the ability to have different button texts on different external \/ affiliate products, since the method via functions.php forces the text on all of them to change to the single text you choose.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So, here&#8217;s the MySQL command to replace text in the products&#8217; <em>_button_text<\/em> field (in bulk):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>UPDATE wp_postmeta SET meta_value = replace(meta_value,'OLD TEXT','NEW TEXT') WHERE meta_key = '_button_text';<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The MySQL method works if you have already entered a custom button text instead of the default <em>Buy product<\/em> text in the <em>Button text<\/em> field of your <em>External \/ Affiliate products<\/em>. This is normally done in the <em>Product data<\/em> section of the regular WooCommerce product editor in the wp-admin area of your website.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you haven&#8217;t changed the default <em>Buy product<\/em> text in the <em>Button text<\/em> field, the particular product won&#8217;t have its <em>_button_text<\/em> field in the <em>wp_postmeta<\/em> MySQL table.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Nevertheless, if you don&#8217;t mind having a fixed single variant of the button text here&#8217;s the functions.php code snippet for changing the default <em>Buy product<\/em> button text to your desired text:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Change Buy product text on product archives pages\nadd_filter('woocommerce_product_add_to_cart_text', 'woocommerce_add_to_cart_button_text', 10, 2);\n\/\/ Change add to cart text on single product page\nadd_filter('woocommerce_product_single_add_to_cart_text', 'woocommerce_add_to_cart_button_text', 10, 2);\n\nfunction woocommerce_add_to_cart_button_text($button_text, $product) {\n    if ('external' == $product-&gt;get_type()) {\n        $button_text = __('New External Link Button Text', 'woocommerce');\n    }\n    return $button_text;\n}<\/code><\/pre>\n\n\n","protected":false},"excerpt":{"rendered":"<p>There&#8217;s an easy way to replace the default WooCommerce Buy product button text on the External \/ Affiliate products by editing the functions.php file of your WordPress theme. But, here I show how to change the button text using MySQL. The MySQL method is helpful if you want to keep the ability to have different [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,16,18],"tags":[],"class_list":["post-264","post","type-post","status-publish","format-standard","hentry","category-tips","category-woocommerce","category-wordpress"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Replace WooCommerce External \/ Affiliate Product Button Text Using MySQL - wproduct<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wproduct.io\/?p=264\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Replace WooCommerce External \/ Affiliate Product Button Text Using MySQL - wproduct\" \/>\n<meta property=\"og:description\" content=\"There&#8217;s an easy way to replace the default WooCommerce Buy product button text on the External \/ Affiliate products by editing the functions.php file of your WordPress theme. But, here I show how to change the button text using MySQL. The MySQL method is helpful if you want to keep the ability to have different [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wproduct.io\/?p=264\" \/>\n<meta property=\"og:site_name\" content=\"wproduct\" \/>\n<meta property=\"article:published_time\" content=\"2024-02-13T12:54:13+00:00\" \/>\n<meta name=\"author\" content=\"danji\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"danji\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/wproduct.io\\\/?p=264#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wproduct.io\\\/?p=264\"},\"author\":{\"name\":\"danji\",\"@id\":\"https:\\\/\\\/wproduct.io\\\/#\\\/schema\\\/person\\\/9334aad829db794714f547b10ade522d\"},\"headline\":\"How to Replace WooCommerce External \\\/ Affiliate Product Button Text Using MySQL\",\"datePublished\":\"2024-02-13T12:54:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/wproduct.io\\\/?p=264\"},\"wordCount\":223,\"commentCount\":0,\"articleSection\":[\"Tips\",\"WooCommerce\",\"WordPress\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/wproduct.io\\\/?p=264#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/wproduct.io\\\/?p=264\",\"url\":\"https:\\\/\\\/wproduct.io\\\/?p=264\",\"name\":\"How to Replace WooCommerce External \\\/ Affiliate Product Button Text Using MySQL - wproduct\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wproduct.io\\\/#website\"},\"datePublished\":\"2024-02-13T12:54:13+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/wproduct.io\\\/#\\\/schema\\\/person\\\/9334aad829db794714f547b10ade522d\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/wproduct.io\\\/?p=264#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/wproduct.io\\\/?p=264\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/wproduct.io\\\/?p=264#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/wproduct.io\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Replace WooCommerce External \\\/ Affiliate Product Button Text Using MySQL\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/wproduct.io\\\/#website\",\"url\":\"https:\\\/\\\/wproduct.io\\\/\",\"name\":\"wproduct\",\"description\":\"Independent E-Commerce with WP and Woo\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/wproduct.io\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/wproduct.io\\\/#\\\/schema\\\/person\\\/9334aad829db794714f547b10ade522d\",\"name\":\"danji\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/edecfe524783e795fd7498294654db6dd846a53fca4e9ca16c93cd6109815152?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/edecfe524783e795fd7498294654db6dd846a53fca4e9ca16c93cd6109815152?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/edecfe524783e795fd7498294654db6dd846a53fca4e9ca16c93cd6109815152?s=96&d=mm&r=g\",\"caption\":\"danji\"},\"sameAs\":[\"https:\\\/\\\/wproduct.io\"],\"url\":\"https:\\\/\\\/wproduct.io\\\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Replace WooCommerce External \/ Affiliate Product Button Text Using MySQL - wproduct","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/wproduct.io\/?p=264","og_locale":"en_US","og_type":"article","og_title":"How to Replace WooCommerce External \/ Affiliate Product Button Text Using MySQL - wproduct","og_description":"There&#8217;s an easy way to replace the default WooCommerce Buy product button text on the External \/ Affiliate products by editing the functions.php file of your WordPress theme. But, here I show how to change the button text using MySQL. The MySQL method is helpful if you want to keep the ability to have different [&hellip;]","og_url":"https:\/\/wproduct.io\/?p=264","og_site_name":"wproduct","article_published_time":"2024-02-13T12:54:13+00:00","author":"danji","twitter_card":"summary_large_image","twitter_misc":{"Written by":"danji","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/wproduct.io\/?p=264#article","isPartOf":{"@id":"https:\/\/wproduct.io\/?p=264"},"author":{"name":"danji","@id":"https:\/\/wproduct.io\/#\/schema\/person\/9334aad829db794714f547b10ade522d"},"headline":"How to Replace WooCommerce External \/ Affiliate Product Button Text Using MySQL","datePublished":"2024-02-13T12:54:13+00:00","mainEntityOfPage":{"@id":"https:\/\/wproduct.io\/?p=264"},"wordCount":223,"commentCount":0,"articleSection":["Tips","WooCommerce","WordPress"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/wproduct.io\/?p=264#respond"]}]},{"@type":"WebPage","@id":"https:\/\/wproduct.io\/?p=264","url":"https:\/\/wproduct.io\/?p=264","name":"How to Replace WooCommerce External \/ Affiliate Product Button Text Using MySQL - wproduct","isPartOf":{"@id":"https:\/\/wproduct.io\/#website"},"datePublished":"2024-02-13T12:54:13+00:00","author":{"@id":"https:\/\/wproduct.io\/#\/schema\/person\/9334aad829db794714f547b10ade522d"},"breadcrumb":{"@id":"https:\/\/wproduct.io\/?p=264#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wproduct.io\/?p=264"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/wproduct.io\/?p=264#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/wproduct.io\/"},{"@type":"ListItem","position":2,"name":"How to Replace WooCommerce External \/ Affiliate Product Button Text Using MySQL"}]},{"@type":"WebSite","@id":"https:\/\/wproduct.io\/#website","url":"https:\/\/wproduct.io\/","name":"wproduct","description":"Independent E-Commerce with WP and Woo","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wproduct.io\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/wproduct.io\/#\/schema\/person\/9334aad829db794714f547b10ade522d","name":"danji","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/edecfe524783e795fd7498294654db6dd846a53fca4e9ca16c93cd6109815152?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/edecfe524783e795fd7498294654db6dd846a53fca4e9ca16c93cd6109815152?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/edecfe524783e795fd7498294654db6dd846a53fca4e9ca16c93cd6109815152?s=96&d=mm&r=g","caption":"danji"},"sameAs":["https:\/\/wproduct.io"],"url":"https:\/\/wproduct.io\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/wproduct.io\/index.php?rest_route=\/wp\/v2\/posts\/264","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wproduct.io\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wproduct.io\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wproduct.io\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wproduct.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=264"}],"version-history":[{"count":0,"href":"https:\/\/wproduct.io\/index.php?rest_route=\/wp\/v2\/posts\/264\/revisions"}],"wp:attachment":[{"href":"https:\/\/wproduct.io\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=264"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wproduct.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=264"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wproduct.io\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}