WordPress.org

Ready to get started?Download WordPress

Forums

WP e-Commerce user roles and purchase history
[resolved] Warning: Missing argument 2 for wpdb::prepare() (8 posts)

  1. plads9000
    Member
    Posted 1 year ago #

    Using WP e-Commerce Version 3.8.9.4 this error show up:

    Warning: Missing argument 2 for wpdb::prepare(), called in /var/www/www.example.com/www/wp-content/plugins/wp-e-commerce-user-roles-and-purchase-history/purchase_history.php on line 54 and defined in /var/www/www.example.com/www/wp-includes/wp-db.php on line 990

    http://wordpress.org/extend/plugins/wp-e-commerce-user-roles-and-purchase-history/

  2. Marjolijn Harvey
    Member
    Posted 1 year ago #

    I've got the same warning coming up after installing and activating.

    The plugin does actually work, however the warning shows up in my Dashboard as well as on the front-end.

    I'm working locally so cannot give you a link, but here is a SCREENSHOT of the front end and a SCREENSHOT of the back-end

    I have just upgraded my WP to 3.5 - plads9000: which version of WP do you have? - maybe it is not compatible yet?
    If this is the case, when will it be compatible? The site is about to go live in the next few days and it would be great if the Manager can actually manage the sales :-)
    Cheers!

  3. Marjolijn Harvey
    Member
    Posted 1 year ago #

    Actually, just found this post on how to add this functionality into your theme's functions.php.

    Just add this code at the bottom LIKE SO:

    //adding extra capability for Editor to access Store Sales and Sales Log//
    add_filter( 'wpsc_purchase_logs_cap', 'wpse_72095_admin_to_editor' );
    
    function wpse_72095_admin_to_editor()
    {
    return 'edit_others_posts'; //modify this according to the role you need to target
    }

    This worked for me! See SCREENSHOT

    Plads9000, let us know if this worked for you too so we can resolve this issue :-)

  4. plads9000
    Member
    Posted 1 year ago #

    Thank you for your reply.

    After writing the post above I installed another plugin, which caused the same error. But after some search I came accross this,

    http://make.wordpress.org/core/2012/12/12/php-warning-missing-argument-2-for-wpdb-prepare/

    I just added, @ini_set('display_errors', 0);, to the ini file and the warning notice is gone.

    As you say and as mentioned in the article, the plugins do work, it's just a new warning.

  5. Marjolijn Harvey
    Member
    Posted 1 year ago #

    That's great news that you managed to solve it too whilst continuing to use the plugin!
    You should mark this thread as resolved :-)

  6. plads9000
    Member
    Posted 1 year ago #

    Yes :-)

  7. Otto Kekäläinen
    Member
    Posted 11 months ago #

    I don't agree that this is solved. Hiding the error message does not solve the problem.

    Line 54 in purchase_history.php should be fixed by project developers:
    $sql = "SELECT COUNT(*) FROM ".WPSC_TABLE_PURCHASE_LOGS." WHERE user_ID IN ('".$user_id."')
    $purchase_count= $wpdb->get_var($wpdb->prepare($sql)) ;

  8. t_papawolf
    Member
    Posted 11 months ago #

    Replace ($wpdb->prepare($sql)) with $wpdb->prepare($query, $args))

    Should work fine.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic