• Resolved Fabricio10

    (@fabriciobarros10)


    /loop/add-to-cart.php
    
    

    global $product;

    if ( $product->product_type == “simple” ) {
    $simpleURL = get_permalink();
    $simpleLabel = “View Product”; // BUTTON LABEL HERE
    } else {
    $simpleURL = $product->add_to_cart_url();
    $simpleLabel = $product->add_to_cart_text();
    };

    echo apply_filters( ‘woocommerce_loop_add_to_cart_link’,
    sprintf( ‘%s‘,
    esc_url( $simpleURL ),
    esc_attr( $product->id ),
    esc_attr( $product->get_sku() ),
    esc_attr( isset( $quantity ) ? $quantity : 1 ),
    $product->is_purchasable() && $product->is_in_stock() ? ‘add_to_cart_button’ : ”,
    esc_attr( $product->product_type ),
    esc_html( $simpleLabel )
    ),
    $product );

    I use this code to redirect the customer to the product page first before making the purchase, but it doesn’t work when your plugin is activated.

    how can i fix this? any code i can edit?

    • This topic was modified 2 years, 9 months ago by Fabricio10.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Fabricio10

    (@fabriciobarros10)

    caddy/public/js/caddy-public.js line 109

    // Custom add to cart functionality
    $( document ).on( ‘click’, ‘.single_add_to_cart_button, .add_to_cart_button’, function( e ) {

    // Custom add to cart functionality
    $( document ).on( ”, ‘.single_add_to_cart_button, .add_to_cart_button’, function( e ) {

    I just removed the word click and it worked again, that’s why I think it enables the page refresh and the code is applied.

    if you have a better solution let me know

    • This reply was modified 2 years, 9 months ago by Fabricio10.
    Plugin Support usecaddy

    (@usecaddy)

    Hey @fabriciobarros10,
    Thanks for letting us know about this. Here’s what we suggest:

    1. Go to caddy/public/js/caddy-public.js file line 165 and remove the if-else condition.
    2. Also, go to caddy/public/class-caddy-public.php file line 99 and replace the code with this line:
    wp_enqueue_script( 'caddy-public', CADDY_DIR_URL . '/public/js/caddy-public.js', array( 'jquery' ), null, true );

    Let us know how it goes!

    Plugin Support usecaddy

    (@usecaddy)

    Hey, @fabriciobarros10 we want to clarify the latest reply:
    We don’t want users to modify the plugin files. This is bad practice in general as changes can get wiped out on updates (and we aim to release frequent updates with improvements).

    It also triggers security plugins to see changes as potential malware because the code does not match the repo.

    Why would you like to redirect to the product first instead of allowing the user to add the item directly to the cart?

    Thread Starter Fabricio10

    (@fabriciobarros10)

    @usecaddy

    Don’t worry, I’m using your puglin to complement my store, I’ll block updates so I don’t lose customization. When I need to update I will make a backup.

    now help me, I didn’t understand which code I should delete and which I should modify, it seems that the line you indicated is not the same as on my site.

    tell me what the codes are precisely so i can edit

    caddy-public.js line 185 a 191 – Remove?

    else {
    
    						// Display product added screen if "notice & caddy window" option is selected with premium
    						cc_cart_screen();
    
    						if ( !$button.hasClass( 'add_to_cart_button' ) ) {
    							$( document.body ).trigger( 'added_to_cart', [response.fragments, response.cart_hash, $button] );
    						}

    line 99 – class-caddy-public.php

    if ( $cc_premium_license_activation ) {
    				$cc_enable_on_checkout_page = get_option( 'cc_enable_on_checkout_page' );
    				if ( 'enabled' !== $cc_enable_on_checkout_page ) {
    					return;
    				}
    			} else {
    				return;
    			}
    		}
    
    		if ( ! wp_script_is( 'jquery' ) ) {
    			wp_enqueue_script( 'jquery', 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js' );
    		}
    		//wp_enqueue_script( 'jquery-ui-tabs' );
    		wp_enqueue_script( 'cc-tabby-js', plugin_dir_url( __FILE__ ) . 'js/tabby.js', array( 'jquery' ), $this->version, true );
    		wp_enqueue_script( 'cc-tabby-polyfills-js', plugin_dir_url( __FILE__ ) . 'js/tabby.polyfills.min.js', array( 'jquery' ), $this->version, true );
    		wp_enqueue_script( 'cc-slick-js', plugin_dir_url( __FILE__ ) . 'js/slick.min.js', array( 'jquery' ), $this->version, true );
    		wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/caddy-public.js', array( 'jquery' ), null, true );
    Plugin Support usecaddy

    (@usecaddy)

    Hey @fabriciobarros10, as explained before we suggest avoiding those edits.
    Stopping the plugin updates can also cause some malfunction in your site, and we can’t provide support if you edit Caddy’s code.

    We’re closing this topic as we don’t want to encourage other people to modify the plugin code.
    Thanks,

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Producr Redirect’ is closed to new replies.