Support » Plugin: WooCommerce » Redirect The Buy Button To Product Page

  • Resolved cwork

    (@cwork)


    Hi.

    The problem is that button.When I click that button, it redirects me to the Amazon page.I need to redirect the link to my website’s product page.Amazon ban you if the link page has no content.I have only two choices.Redirecting or hiding the button.You’ll see in the video when I try to hide button, blank space getting larger and it’s not about image size.I changed image size but nothing changed. Can you help me?

    Video

    My website is in maintenance mode so I can’t share the link.
    *Website created for the affiliate.

Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Support Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    Amazon ban you if the link page has no content. I have only two choices.

    The link page would have content though? It just depends on what the user clicks.

    This is the expected default behavior. Hiding the button is the easiest fix, but I can’t help with CSS without being able to view the page.

    The other option is a PHP snippet to change the buy button link to go to the product page first. Can use this filter for that: https://github.com/woocommerce/woocommerce/blob/master/templates/loop/add-to-cart.php#L25

    cwork

    (@cwork)

    @icaleb I checked the code and found the file from cPanel but codes are same.Please understand my situation. I know nothing about HTML,PHP or CSS.What should I do?

    Plugin Support Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    Right, so the filter needs to be used outside of the main files.

    Here is the snippet you need: https://gist.github.com/WPprodigy/9b0a4797a178cfb68bb019f1e03e9e42

    Here is a guide on adding custom code to your site: https://calebburks.com/correctly-add-custom-code-woocommerce/

    cwork

    (@cwork)

    @icaleb Thank you very much code works but it caused an error .

    I’ve tried code snippet and directly paste to the functions.php file.Same.In the meantime, thanks for the code snippet plugin.

    Two more things.How can I move the buy button to the right side?

    My final question is, can I change the (buy)button’s name on the just product page?Is that possible?

    Thanks in advance.

    • This reply was modified 1 year ago by  cwork.
    Plugin Support Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    Did you get it working with the code snippets plugin? I’m thinking it was just placed in the wrong place in the functions.php theme file.

    And then what if you instead just changed the button text on the product listing/catalog pages? You can then just use the button text setting for the single product page button.

    That way you can use the above snippet, and just replace $product->add_to_cart_text() with 'your text here'. I added a comment to the above gist on how this would be done for only external products: https://gist.github.com/WPprodigy/9b0a4797a178cfb68bb019f1e03e9e42

    cwork

    (@cwork)

    @icaleb

    -I installed code snippets plugin, clicked add new code then I pasted the code and error.
    -I deactivated the plugin and pasted the code to end of the functions.php file
    still same error.That’s all.

    Plugin Support Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    403 Forbidden error doesn’t really make sense, this happened when you tried pasting the code both times? The code is fine, so must be with how it’s being added and I’m afraid there isn’t much more I can do to help in that area.

    Might need to hire a developer for further help with custom code:

    http://jobs.wordpress.net/
    https://codeable.io/
    https://woocommerce.com/experts/

    cwork

    (@cwork)

    @icaleb

    I recorded all process as a video.Please watch.

    Plugin Support Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    Ohh, what version of WooCommerce are you using? Thanks for the video by the way.

    Need to be using a newer versions to use the above code snippets, as the third parameter $args was recently added to the filter to make snippets like this possible πŸ™‚

    cwork

    (@cwork)

    I use 3.3.4.I always update it.I haven’t edited any code in the cPanel for the last update because I don’t see any error on the WC-Status-Templates(Overrides).Should I do something? @icaleb

    Plugin Support Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    Could you post your system status report? More specifically, is your theme overriding the templates/loop/add-to-cart.php template?

    cwork

    (@cwork)

    @icaleb

    
    ### WordPress Environment ###
    
    Home URL: http://www.caseroll.com
    Site URL: http://www.caseroll.com
    WC Version: 3.3.4
    Log Directory Writable: βœ”
    WP Version: 4.9.4
    WP Multisite: –
    WP Memory Limit: 768 MB
    WP Debug Mode: –
    WP Cron: βœ”
    Language: en_US
    
    ### Server Environment ###
    
    Server Info: Apache
    PHP Version: 5.6.34
    PHP Post Max Size: 128 MB
    PHP Time Limit: 120
    PHP Max Input Vars: 3000
    cURL Version: 7.53.0
    OpenSSL/1.0.2k
    
    SUHOSIN Installed: –
    MySQL Version: 5.6.36
    Max Upload Size: 128 MB
    Default Timezone is UTC: βœ”
    fsockopen/cURL: βœ”
    SoapClient: βœ”
    DOMDocument: βœ”
    GZip: βœ”
    Multibyte String: βœ”
    Remote Post: βœ”
    Remote Get: βœ”
    
    ### Database ###
    
    WC Database Version: 3.3.4
    WC Database Prefix: wpnlew_
    Total Database Size: 35.31MB
    Database Data Size: 31.12MB
    Database Index Size: 4.19MB
    wpnlew_woocommerce_sessions: Data: 0.01MB + Index: 0.00MB
    wpnlew_woocommerce_api_keys: Data: 0.00MB + Index: 0.00MB
    wpnlew_woocommerce_attribute_taxonomies: Data: 0.00MB + Index: 0.01MB
    wpnlew_woocommerce_downloadable_product_permissions: Data: 0.00MB + Index: 0.00MB
    wpnlew_woocommerce_order_items: Data: 0.00MB + Index: 0.00MB
    wpnlew_woocommerce_order_itemmeta: Data: 0.00MB + Index: 0.00MB
    wpnlew_woocommerce_tax_rates: Data: 0.00MB + Index: 0.00MB
    wpnlew_woocommerce_tax_rate_locations: Data: 0.00MB + Index: 0.00MB
    wpnlew_woocommerce_shipping_zones: Data: 0.00MB + Index: 0.00MB
    wpnlew_woocommerce_shipping_zone_locations: Data: 0.00MB + Index: 0.00MB
    wpnlew_woocommerce_shipping_zone_methods: Data: 0.00MB + Index: 0.00MB
    wpnlew_woocommerce_payment_tokens: Data: 0.00MB + Index: 0.00MB
    wpnlew_woocommerce_payment_tokenmeta: Data: 0.00MB + Index: 0.00MB
    wpnlew_woocommerce_log: Data: 0.00MB + Index: 0.00MB
    wpnlew_aiowps_events: Data: 0.00MB + Index: 0.00MB
    wpnlew_aiowps_failed_logins: Data: 0.00MB + Index: 0.00MB
    wpnlew_aiowps_global_meta: Data: 0.00MB + Index: 0.00MB
    wpnlew_aiowps_login_activity: Data: 0.00MB + Index: 0.00MB
    wpnlew_aiowps_login_lockdown: Data: 0.00MB + Index: 0.00MB
    wpnlew_aiowps_permanent_block: Data: 0.00MB + Index: 0.00MB
    wpnlew_alm: Data: 0.00MB + Index: 0.00MB
    wpnlew_amz_amzkeys: Data: 2.83MB + Index: 0.01MB
    wpnlew_amz_assets: Data: 0.62MB + Index: 0.05MB
    wpnlew_amz_cross_sell: Data: 0.00MB + Index: 0.00MB
    wpnlew_amz_locale_reference: Data: 0.08MB + Index: 0.04MB
    wpnlew_amz_products: Data: 0.09MB + Index: 0.09MB
    wpnlew_amz_queue: Data: 0.03MB + Index: 0.01MB
    wpnlew_amz_report_log: Data: 13.96MB + Index: 0.03MB
    wpnlew_amz_search: Data: 0.00MB + Index: 0.01MB
    wpnlew_cf_forms: Data: 0.02MB + Index: 0.02MB
    wpnlew_cf_form_entries: Data: 0.02MB + Index: 0.06MB
    wpnlew_cf_form_entry_meta: Data: 0.02MB + Index: 0.03MB
    wpnlew_cf_form_entry_values: Data: 0.02MB + Index: 0.05MB
    wpnlew_cf_pro_messages: Data: 0.02MB + Index: 0.00MB
    wpnlew_cf_tracking: Data: 0.02MB + Index: 0.00MB
    wpnlew_cf_tracking_meta: Data: 0.02MB + Index: 0.03MB
    wpnlew_commentmeta: Data: 0.01MB + Index: 0.01MB
    wpnlew_comments: Data: 0.00MB + Index: 0.01MB
    wpnlew_ewwwio_images: Data: 2.75MB + Index: 0.79MB
    wpnlew_ip_geo_block_cache: Data: 0.02MB + Index: 0.02MB
    wpnlew_ip_geo_block_logs: Data: 0.02MB + Index: 0.03MB
    wpnlew_ip_geo_block_stat: Data: 0.02MB + Index: 0.00MB
    wpnlew_links: Data: 0.00MB + Index: 0.00MB
    wpnlew_newsletter: Data: 0.00MB + Index: 0.00MB
    wpnlew_newsletter_emails: Data: 0.00MB + Index: 0.00MB
    wpnlew_newsletter_sent: Data: 0.00MB + Index: 0.00MB
    wpnlew_newsletter_stats: Data: 0.00MB + Index: 0.00MB
    wpnlew_nf3_actions: Data: 0.00MB + Index: 0.00MB
    wpnlew_nf3_action_meta: Data: 0.00MB + Index: 0.00MB
    wpnlew_nf3_fields: Data: 0.00MB + Index: 0.00MB
    wpnlew_nf3_field_meta: Data: 0.01MB + Index: 0.01MB
    wpnlew_nf3_forms: Data: 0.00MB + Index: 0.00MB
    wpnlew_nf3_form_meta: Data: 0.00MB + Index: 0.00MB
    wpnlew_nf3_objects: Data: 0.00MB + Index: 0.00MB
    wpnlew_nf3_object_meta: Data: 0.00MB + Index: 0.00MB
    wpnlew_nf3_relationships: Data: 0.00MB + Index: 0.00MB
    wpnlew_optins: Data: 0.02MB + Index: 0.03MB
    wpnlew_optin_meta: Data: 0.02MB + Index: 0.03MB
    wpnlew_options: Data: 1.77MB + Index: 0.25MB
    wpnlew_postmeta: Data: 2.60MB + Index: 0.76MB
    wpnlew_posts: Data: 1.63MB + Index: 0.19MB
    wpnlew_redirection_404: Data: 0.02MB + Index: 0.06MB
    wpnlew_redirection_groups: Data: 0.02MB + Index: 0.03MB
    wpnlew_redirection_items: Data: 0.02MB + Index: 0.08MB
    wpnlew_redirection_logs: Data: 0.05MB + Index: 0.08MB
    wpnlew_rm_fields: Data: 0.02MB + Index: 0.00MB
    wpnlew_rm_forms: Data: 0.02MB + Index: 0.00MB
    wpnlew_rm_front_users: Data: 0.02MB + Index: 0.00MB
    wpnlew_rm_notes: Data: 0.02MB + Index: 0.00MB
    wpnlew_rm_paypal_fields: Data: 0.02MB + Index: 0.00MB
    wpnlew_rm_paypal_logs: Data: 0.02MB + Index: 0.00MB
    wpnlew_rm_rules: Data: 0.02MB + Index: 0.00MB
    wpnlew_rm_sent_mails: Data: 0.02MB + Index: 0.00MB
    wpnlew_rm_sessions: Data: 0.02MB + Index: 0.00MB
    wpnlew_rm_stats: Data: 0.02MB + Index: 0.00MB
    wpnlew_rm_submissions: Data: 0.02MB + Index: 0.00MB
    wpnlew_rm_submission_fields: Data: 0.02MB + Index: 0.00MB
    wpnlew_rm_tasks: Data: 0.02MB + Index: 0.00MB
    wpnlew_rm_task_exe_log: Data: 0.02MB + Index: 0.00MB
    wpnlew_snippets: Data: 0.02MB + Index: 0.00MB
    wpnlew_statistics_exclusions: Data: 0.02MB + Index: 0.03MB
    wpnlew_statistics_historical: Data: 0.02MB + Index: 0.05MB
    wpnlew_statistics_pages: Data: 0.02MB + Index: 0.05MB
    wpnlew_statistics_search: Data: 0.02MB + Index: 0.05MB
    wpnlew_statistics_useronline: Data: 0.02MB + Index: 0.00MB
    wpnlew_statistics_visit: Data: 0.02MB + Index: 0.02MB
    wpnlew_statistics_visitor: Data: 0.06MB + Index: 0.08MB
    wpnlew_termmeta: Data: 0.01MB + Index: 0.02MB
    wpnlew_terms: Data: 0.01MB + Index: 0.03MB
    wpnlew_term_relationships: Data: 0.03MB + Index: 0.06MB
    wpnlew_term_taxonomy: Data: 0.01MB + Index: 0.01MB
    wpnlew_usermeta: Data: 0.01MB + Index: 0.02MB
    wpnlew_users: Data: 0.00MB + Index: 0.01MB
    wpnlew_wc_comments_subscription: Data: 0.00MB + Index: 0.00MB
    wpnlew_wc_download_log: Data: 0.02MB + Index: 0.03MB
    wpnlew_wc_phrases: Data: 0.00MB + Index: 0.00MB
    wpnlew_wc_users_voted: Data: 0.00MB + Index: 0.00MB
    wpnlew_wc_webhooks: Data: 0.02MB + Index: 0.02MB
    wpnlew_wfBadLeechers: Data: 0.00MB + Index: 0.00MB
    wpnlew_wfBlockedCommentLog: Data: 0.02MB + Index: 0.00MB
    wpnlew_wfBlockedIPLog: Data: 0.00MB + Index: 0.00MB
    wpnlew_wfBlocks: Data: 0.00MB + Index: 0.00MB
    wpnlew_wfBlocks7: Data: 0.02MB + Index: 0.05MB
    wpnlew_wfBlocksAdv: Data: 0.00MB + Index: 0.00MB
    wpnlew_wfConfig: Data: 0.25MB + Index: 0.01MB
    wpnlew_wfCrawlers: Data: 0.00MB + Index: 0.00MB
    wpnlew_wfFileChanges: Data: 0.02MB + Index: 0.00MB
    wpnlew_wfFileMods: Data: 0.97MB + Index: 0.22MB
    wpnlew_wfHits: Data: 0.72MB + Index: 0.16MB
    wpnlew_wfHoover: Data: 0.59MB + Index: 0.08MB
    wpnlew_wfIssues: Data: 0.01MB + Index: 0.01MB
    wpnlew_wfKnownFileList: Data: 0.47MB + Index: 0.07MB
    wpnlew_wfLeechers: Data: 0.02MB + Index: 0.02MB
    wpnlew_wfLockedOut: Data: 0.00MB + Index: 0.00MB
    wpnlew_wfLocs: Data: 0.00MB + Index: 0.00MB
    wpnlew_wfLogins: Data: 0.07MB + Index: 0.02MB
    wpnlew_wfNet404s: Data: 0.00MB + Index: 0.00MB
    wpnlew_wfNotifications: Data: 0.02MB + Index: 0.01MB
    wpnlew_wfPendingIssues: Data: 0.00MB + Index: 0.00MB
    wpnlew_wfReverseCache: Data: 0.00MB + Index: 0.00MB
    wpnlew_wfScanners: Data: 0.01MB + Index: 0.01MB
    wpnlew_wfSNIPCache: Data: 0.00MB + Index: 0.00MB
    wpnlew_wfStatus: Data: 0.11MB + Index: 0.05MB
    wpnlew_wfThrottleLog: Data: 0.00MB + Index: 0.00MB
    wpnlew_wfVulnScanners: Data: 0.00MB + Index: 0.00MB
    wpnlew_woof_query_cache: Data: 0.00MB + Index: 0.00MB
    wpnlew_wpmm_subscribers: Data: 0.02MB + Index: 0.00MB
    wpnlew_yith_wcwl: Data: 0.02MB + Index: 0.02MB
    wpnlew_yith_wcwl_lists: Data: 0.02MB + Index: 0.03MB
    wpnlew_yoast_seo_links: Data: 0.38MB + Index: 0.13MB
    wpnlew_yoast_seo_meta: Data: 0.05MB + Index: 0.00MB
    
    ### Post Type Counts ###
    
    amn_mi-lite: 1
    amn_wpforms-lite: 4
    attachment: 151
    custom_css: 2
    customize_changeset: 156
    hrf_faq: 7
    mc4wp-form: 2
    nav_menu_item: 6
    page: 17
    post: 4
    postman_sent_mail: 1
    product: 258
    revision: 730
    ufaq: 3
    wpdiscuz_form: 1
    wpforms: 1
    yith-wcbm-badge: 2
    
    ### Security ###
    
    Secure connection (HTTPS): ❌Your store is not using HTTPS. Learn more about HTTPS and SSL Certificates.
    Hide errors from visitors: βœ”
    
    ### Active Plugins (22) ###
    
    Akismet Anti-Spam: by Automattic – 4.0.3
    Code Snippets: by Shea Bunge – 2.10.1.1
    Elementor: by Elementor.com – 2.0.2
    Force Regenerate Thumbnails: by Pedro Elsner – 2.0.6
    Fullwidth Page Templates: by Brainstorm Force – 1.0.2
    Hide Title: by Brandon Kraft & Randall Runnels – 1.0.4
    Insert Headers and Footers: by WPBeginner – 1.4.2
    Kirki Toolkit: by Aristeides Stathopoulos – 3.0.25
    Maintenance: by fruitfulcode – 3.6.1
    MetaSlider: by Team Updraft – 3.7.2
    reSmush.it Image Optimizer: by Maecia – 0.1.13
    Woo Title Limit: by Dima W. – 1.4.1 – Not tested with the active version of WooCommerce
    WooCommerce Extra Product Sorting Options: by SkyVerge – 2.7.1 – Not tested with the active version of WooCommerce
    WooCommerce: by Automattic – 3.3.4
    WooZone - WooCommerce Amazon Affiliates: by AA-Team – 9.3 – Not tested with the active version of WooCommerce
    Wordfence Security: by Wordfence – 7.1.1
    Yoast SEO: by Team Yoast – 7.1
    WP Fastest Cache: by Emre Vona – 0.8.7.8
    WP Mail SMTP: by WPForms – 1.2.5
    WPForms Lite: by WPForms – 1.4.5.2
    WPS Hide Login: by WPServeur
    NicolasKulka
    tabrisrp – 1.2.6.1
    
    YITH WooCommerce Badge Management: by YITHEMES – 1.3.9 – Not tested with the active version of WooCommerce
    
    ### Settings ###
    
    API Enabled: βœ”
    Force SSL: –
    Currency: USD ($)
    Currency Position: left
    Thousand Separator: ,
    Decimal Separator: .
    Number of Decimals: 2
    Taxonomies: Product Types: external (external)
    grouped (grouped)
    simple (simple)
    variable (variable)
    
    Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)
    exclude-from-search (exclude-from-search)
    featured (featured)
    outofstock (outofstock)
    rated-1 (rated-1)
    rated-2 (rated-2)
    rated-3 (rated-3)
    rated-4 (rated-4)
    rated-5 (rated-5)
    
    ### WC Pages ###
    
    Shop base: #9 - /
    Cart: #7223 - /cart/
    Checkout: #7225 - /checkout/
    My account: #7248 - /my-account/
    Terms and conditions: ❌ Page not set
    
    ### Theme ###
    
    Name: Ocin
    Version: 1.4.7
    Author URL: https://www.quemalabs.com/
    Child Theme: ❌ – If you are modifying WooCommerce on a parent theme that you did not build personally we recommend using a child theme. See: How to create a child theme
    WooCommerce Support: βœ”
    
    ### Templates ###
    
    Overrides: ocin/woocommerce/cart/cart.php
    ocin/woocommerce/cart/mini-cart.php
    ocin/woocommerce/loop/add-to-cart.php
    ocin/woocommerce/loop/loop-start.php
    ocin/woocommerce/loop/pagination.php
    ocin/woocommerce/single-product/product-image.php
    ocin/woocommerce/single-product/product-thumbnails.php
    
    
    Plugin Support Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    Right, so your theme is overriding the template I mentioned, and it is not up to date (or rather the theme authors updated the version number but did not implement the changes that were made).

    Need to have the template correctly updated to pass along the $args parameter: https://github.com/woocommerce/woocommerce/blob/master/templates/loop/add-to-cart.php#L33

    cwork

    (@cwork)

    YOU SUCCEEDED! YOU SUCCEEDED! Thank you very very much for everything.In the meantime, thank you for your patience.

    I have different question πŸ˜€ Should I create a new topic for this?

    Question is: I need to set product category for each product page.You saw Bags and Shoes Pages are different.When I delete “removing category css code” I see all categories.

    For example, the page is bag’s page.I need only backpacks, shoulder bags, wallets etc
    if the page is shoe page I need to see only pumps, sneakers, sandals etc.

    How can I do this?

    Thanks again

    Plugin Support Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    I don’t think you need anything special for this, just need to utilize the default category pages.

    1) Assign products to only categories they belong to.
    2) Use / link to the default category pages. At Products > Categories you can click “view” underneath a category to see it’s page and get the link.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Redirect The Buy Button To Product Page’ is closed to new replies.