Forum Replies Created

Viewing 15 replies - 31 through 45 (of 45 total)
  • Thread Starter ITP TECHNOLOGIE

    (@abitp)

    UP

    Thread Starter ITP TECHNOLOGIE

    (@abitp)

    I’ve solved the problem by disabling your product search system.

    With a WordPress site containing <span style=”text-decoration: underline;”>70,000 products</span>, your search feature, or even just opening a ticket, causes my site to crash.

    Same error

    Thread Starter ITP TECHNOLOGIE

    (@abitp)

    Ok !
    If I understood correctly, I’ll just wait for your patch and include it in my new website version.
    Thanks a lot.

    Thread Starter ITP TECHNOLOGIE

    (@abitp)

    Hi,
    It never worked.
    Here’s the page concerned, maybe you can check the scripts called …
    https://www.itp-technologie.com/wp-login.php
    I double checked the site key and secret key.
    Cheers

    Thread Starter ITP TECHNOLOGIE

    (@abitp)

    Hi,
    I keep getting Login google_recaptcha_v3 invalid-input-response
    I didn’t try regenerate recaptcha keys. It works on woocommerce login though (the login works, and the recaptcha works as well).
    Lowering the score to 0.3 didn’t work at all.
    Cheers

    Thread Starter ITP TECHNOLOGIE

    (@abitp)

    Ok I just figured some code that WORKS and include my “wc-expedier” custom status.
    Here’s the code that works :

    global $count_real;
        $args = array(
            'customer_id' => $my_user_id_itp,
            'post_status' => 'any',
            'post_type' => 'shop_order',
            'return' => 'ids',
            'limit' => -1
        );
        $count_real = 0;
        $count_real = count( wc_get_orders( $args ) ); // count the array of orders

    Even with a customer that only has 2 orders with the custom status “wc-expedier”, it shows “2” when before it showed “0”.

    I’m so glad !

    I hope this query doesn’t charge too much the server and isn’t overkill.

    Let me know if there’s anything wrong or not fully optimised …

    Cheers

    Thread Starter ITP TECHNOLOGIE

    (@abitp)

    Hi,

    `$orders = wc_get_orders(array(
    ‘customer_id’ => get_current_user_id(),
    ‘return’ => ‘ids’,
    ));
    echo count($orders);`

    Returns “2” whatever the current user is.

    Should I go back to the rs_get_all_orders function previously presented ?

    Edit : I still can’t include my orders with the custom order statuses in my order count, even with the previously mentioned code.

    Cheers

    Thread Starter ITP TECHNOLOGIE

    (@abitp)

    Hi,
    Here’s the code I wrote in my functions.php :

    
    if(is_user_logged_in())
    {
    $my_user_id = get_current_user_id();
        $customer = new WC_Customer( $my_user_id );
        $statuses = array('processing','expedier','completed', 'refunded', 'pending', 'on-hold');
        global $count_real;
        $count_real = $customer->get_order_count($statuses);
    }

    Where “expedier” is the custom order status I’ve mentioned.

    Does it seem correct ?

    Cheers

    • This reply was modified 3 years, 2 months ago by ITP TECHNOLOGIE. Reason: replacing the code tag correctly
    Thread Starter ITP TECHNOLOGIE

    (@abitp)

    Hi,

    As I read your question about the order statuses,
    I thought maybe the problem was because of these orders have one of my custom order status.

    I’m using this plugin : WooCommerce Order Status Manager https://woocommerce.com/fr-fr/products/woocommerce-order-status-manager/

    As I changed the client order statuses to “completed”, the order count worked out and showed “3”.

    Do you still need a screenshot ?

    Also is this a woocommerce / plugin update situation ?

    Cheers

    Thread Starter ITP TECHNOLOGIE

    (@abitp)

    Hi,

    Thank you for your reply.
    I slightly edited the code because I’m not using the woocommerce_account_navigation hook.
    (code below)
    For the customer I keep mentionning (who has actually 3 orders but on the front end it says zero) : I got this result : Total orders: 0.

    Not okay :/

    (the code I slightly edited and put in my functions.php as asked)

    add_action( 'woocommerce_order_details_before_order_table', 'rs_get_all_orders' );
    
    function rs_get_all_orders() {
    
    if ( is_user_logged_in() ) {
    
        $user_id = get_current_user_id();
    
        $customer = new WC_Customer( $user_id );
    
        $last_order = $customer->get_last_order();
    
        $order_id     = $last_order->get_id();
        $order_data   = $last_order->get_data();
        $order_status = $last_order->get_status();
    	
    	$result = wc_get_customer_order_count( $user_id );
    
    	foreach ( $last_order->get_items() as $item ) {
    		
    		echo ( '<p style="display:none;" id="test">Total orders: ' . $result . '</p>' );
    		} 
    	} 
    }
    Thread Starter ITP TECHNOLOGIE

    (@abitp)

    Hi @rynald0s, thank you for your reply.
    I am trying to output it on the “my account – edit account details”. I’m calling it front end because it’s not in wp-admin.

    I’m inserting the code here.

    <?php
    /**
     * Edit address form
     *
     * This template can be overridden by copying it to yourtheme/woocommerce/myaccount/form-edit-address.php.
     *
     * HOWEVER, on occasion WooCommerce will need to update template files and you
     * (the theme developer) will need to copy the new files to your theme to
     * maintain compatibility. We try to do this as little as possible, but it does
     * happen. When this occurs the version of the template file will be bumped and
     * the readme will list any important changes.
     *
     * @see https://docs.woocommerce.com/document/template-structure/
     * @package WooCommerce\Templates
     * @version 3.6.0
     */
    
    defined( 'ABSPATH' ) || exit;
    
    $page_title = ( 'billing' === $load_address ) ? esc_html__( 'Billing address', 'woocommerce' ) : esc_html__( 'Shipping address', 'woocommerce' );
    $slugok = sanitize_title($page_title);
    do_action( 'woocommerce_before_edit_account_address_form' ); ?>
    
    <?php if ( ! $load_address ) : ?>
    	<?php wc_get_template( 'myaccount/my-address.php' ); ?>
    <?php else : ?>
    
    	<form method="post">
    
    		<h3><?php echo apply_filters( 'woocommerce_my_account_edit_address_title', $page_title, $load_address ); ?></h3><?php // @codingStandardsIgnoreLine ?>
    
    		<div class="woocommerce-address-fields <?php echo $slugok;?>">
    			<?php do_action( "woocommerce_before_edit_address_form_{$load_address}" ); ?>
    
    			<div class="woocommerce-address-fields__field-wrapper">
    				<?php
    				if($slugok == 'adresse-de-facturation')
    				{
    					global $my_user_id;
    					$dejacommande = wc_get_customer_order_count( $my_user_id );
    					$disabled = ($dejacommande >= 1) ? 'disabled_' : '';
    					$readonly = ($dejacommande >= 1) ? ['readonly' => true] : '';
    
    					$args = [
    						'author' => $my_user_id,
    						'post_status' => 'any',
    						'post_type' => 'shop_order'
    					];
    					
    					$query = new WP_Query($args);
    					$totalcount = $query->found_posts;
    					echo '<div class="test_" style="display:none;">'.$totalcount.'</div>';
    					echo '<div class="test_" style="display:none;">'.$my_user_id.'</div>';
    					
    				}
    				
    				foreach ( $address as $key => $field ) {
    					if($slugok == 'adresse-de-facturation')
    					{
    						array_push($field['class'],$disabled);
    						$field['custom_attributes'] = $readonly;
    					}
    					woocommerce_form_field( $key, $field, wc_get_post_data_by_key( $key, $field['value'] ) );
    				}
    				?>
    			</div>
    
    			<?php do_action( "woocommerce_after_edit_address_form_{$load_address}" ); ?>
    
    			<p>
    				<button type="submit" class="button" name="save_address" value="<?php esc_attr_e( 'Save address', 'woocommerce' ); ?>"><?php esc_html_e( 'Save address', 'woocommerce' ); ?></button>
    				<?php wp_nonce_field( 'woocommerce-edit_address', 'woocommerce-edit-address-nonce' ); ?>
    				<input type="hidden" name="action" value="edit_address" />
    			</p>
    		</div>
    
    	</form>
    
    <?php endif; ?>
    
    <?php do_action( 'woocommerce_after_edit_account_address_form' ); ?>
    

    The variables $totalcount and $dejacommande both return “0” for the clients that have this bug (when they actually have some orders).

    Thread Starter ITP TECHNOLOGIE

    (@abitp)

    Hi,

    Thank you for your message.
    I would say it’s not helping for my situation here.

    I just want the order count for the current user on the front end, just like it’s displayed correctly in the wp admin.

    My problem is that on the front end the system considers that this user has 0 order, when asked using wc_get_customer_order_count. However, still on the front end, when this client goes to “my-orders” his orders are actually displayed correctly. Same for when I go to wp admin.

    How is that possible ?

    How to fix it ?

    Thanks

    Thread Starter ITP TECHNOLOGIE

    (@abitp)

    Hi,

    Thank you, I’ve been exactly using it as the tutorial / Hookr instructions tell.
    As I say, it’s working for most of my users.
    But somehow, for recently registered users, it’s -> Not working. It’s returning “0” as order counts, even if this recently registered user has already ordered more than once.

    Also my code is as follows :

    global $my_user_id;
    $dejacommande = wc_get_customer_order_count( $my_user_id);

    I also tried using :

    $args = [
    'author' => $my_user_id,
    'post_status' => 'any',
    'post_type' => 'shop_order'
    ];

    $query = new WP_Query($args);
    $totalcount = $query->found_posts;

    And none work for recently registered users. It works for other users.

    Thread Starter ITP TECHNOLOGIE

    (@abitp)

    Here is the record I have from a bot login attempt, I removed sensible datas

    `id ID
    logger SimpleUserLogger
    level warning
    date 2021-08-23 09:54:07
    message Failed to login with username “{failed_username}” (username does not exist)
    initiator web_user
    context_message_key user_unknown_login_failed
    failed_username it’s an admin username but with bad special character
    server_http_user_agent Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0
    _message_key user_unknown_login_failed
    _server_remote_addr ip
    _server_http_x_forwarded_for_0 same ip

Viewing 15 replies - 31 through 45 (of 45 total)