Support » Plugin: Abandoned Cart Lite for WooCommerce » code suggestions

  • Resolved Edith

    (@terragirl)


    Plugin is easy to install & use, very clear and does what it says – thank you!

    Couple of minor code suggestions:

    The unubscribe link can lead to unintended redirects on WordPress sites where the siteurl and home url differ. On reaching a non existing siteurl, the site will either display the 404 page or the canonical redirect will kick in, redirecting to an unintended page.

    Suggested solution:

    File: woocommerce-ac.php on line 1673
    replace
    $url = get_option( ‘siteurl’ );
    with
    $url = get_option( ‘home’ );

    File: /cron/wcal_send_email.php on line 252
    replace
    $cart_link_track = get_option(‘siteurl’).’/?wcal_action=track_links&validate=’ . $validate_cart;
    with
    $cart_link_track = get_option(‘home’).’/?wcal_action=track_links&validate=’ . $validate_cart;

    File: /cron/wcal_send_email.php on line 260
    replace
    $plugins_url = get_option( ‘siteurl’ ) . “/?wcal_track_unsubscribe=wcal_unsubscribe&validate=” . $validate_unsubscribe . “&track_email_id=” . $encrypt_email_sent_id_address;
    with
    $plugins_url = get_option( ‘home’ ) . “/?wcal_track_unsubscribe=wcal_unsubscribe&validate=” . $validate_unsubscribe . “&track_email_id=” . $encrypt_email_sent_id_address;

    Secondly for guest visitors currently the field displays empty if name is unknown leading to “Dear ;” in the email when eg using {{customer.fullname}} in the template. Instead of if isset() the code should use if !empty() in /cron/wcal_send_email.php, lines 172 onwards like so:

    if ( $value->user_type == “GUEST” ) {

    if ( empty($results_guest[0]->billing_first_name) && empty($results_guest[0]->billing_last_name ) ) {

    if ( (strpos($email_body, “{{customer.firstname}}”)!==false) && (strpos($email_body, “{{customer.lastname}}”)!== false) ) {
    $email_body = str_replace( “{{customer.firstname}}”,””, $email_body );
    $email_body = str_replace( “{{customer.lastname}}”, __( “Customer”, “woocommerce-abandoned-cart” ), $email_body );
    } elseif (strpos($email_body, “{{customer.firstname}}”)!==false) {
    $email_body = str_replace( “{{customer.firstname}}”, __( “Customer”, “woocommerce-abandoned-cart” ), $email_body );
    } elseif (strpos($email_body, “{{customer.lastname}}”)!==false) {
    $email_body = str_replace( “{{customer.lastname}}”, __( “Customer”, “woocommerce-abandoned-cart” ), $email_body );
    }

    $email_body = str_replace( “{{customer.fullname}}”, __( “Customer”, “woocommerce-abandoned-cart” ), $email_body );
    } else {

    if ( !empty( $results_guest[0]->billing_first_name ) ) {
    $email_body = str_replace( “{{customer.firstname}}”, $results_guest[0]->billing_first_name, $email_body );
    $email_subject = str_replace( “{{customer.firstname}}”, $results_guest[0]->billing_first_name, $email_subject );
    }
    if ( !empty( $results_guest[0]->billing_last_name ) ) {
    $email_body = str_replace( “{{customer.lastname}}”, $results_guest[0]->billing_last_name, $email_body );
    }
    if ( !empty( $results_guest[0]->billing_first_name ) && !empty( $results_guest[0]->billing_last_name ) ) {
    $email_body = str_replace( “{{customer.fullname}}”, $results_guest[0]->billing_first_name.” “.$results_guest[0]->billing_last_name, $email_body );
    }
    else if ( !empty( $results_guest[0]->billing_first_name ) ) {
    $email_body = str_replace( “{{customer.fullname}}”, $results_guest[0]->billing_first_name, $email_body );
    }
    else if ( !empty( $results_guest[0]->billing_last_name ) ) {
    $email_body = str_replace( “{{customer.fullname}}”, $results_guest[0]->billing_last_name, $email_body );
    }

    }

    } else {

Viewing 1 replies (of 1 total)
  • Plugin Author chetnapatel

    (@chetnapatel)

    Hi,

    I’m glad to know that you are able to solve the issue. Thank you for sharing the solution which worked on your site. I really appreciate it.

    1) About the URL of the SITE,

    We may need the relative path of the site and hence we may need site_url but we can verify by changing your solution in our plugin.

    We have to check whether the same solution will work for all the environment of the websites or not then we can implement this solution in our plugin. I will look into it, and apply the permanent fix which works on all setup.

    2) For the second suggestion,

    Yes, I agree with you. I will surely change the code and include this solution in our plugin.

    Thank you once again for your suggestion. Please let me know if you have any queries.

    Regards,
    Chetna Bhutka

Viewing 1 replies (of 1 total)
  • The topic ‘code suggestions’ is closed to new replies.