Foreach loop posting content twice

已完成 已发布的 5 年前 货到付款
已完成 货到付款

My plugin pulls values from custom meta data on an order and posts it to discord. I made a change to the script and now it's double posting the custom meta data.

The full file of the script is uploaded as well as an example file that contains just the loop. The loop can be found in the full file as well.

On line 22 I changed

add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'send_order' ), 15 );

To

add_action( 'woocommerce_order_status_processing', array( $this, 'send_order' ), 15 );

Once I change to the status woocommerce_order_status_processing my forloop starts double posting everything. I need the double posting to stop.

Example of how the discord post looks

Bob Joe <-- clients name

Order #123123 <-- order number

Brand New Tee Shirt <-- Product Name

Color: Red <-- What should post

Size: Medium

Color: Red <-- Double post

Size Medium

Only custom options double up and only with that one filter set. I need that filter set though or at least one that triggers when a post is set to processing.

Solution should only trigger when set to processing.

PHP WordPress

项目ID: #18357567

关于项目

4个方案 远程项目 活跃的5 年前

授予:

maya261

I am here to help you with the foreach loop. Send me a message to discuss it. I am ready to start work right now

$30 USD 在1天内
(12条评论)
4.1

有4名威客正在参与此工作的竞标,均价$31/小时

alyaspk

Hi, I am ready to fix your loop issue and assure 100% satisfaction guarantee. Please have a look on my profile to see my past work and reviews. Looking forward to your kind response. Regards Muhammad Alyas

$29USD 在1天里
(213条评论)
7.5
adityasharma91

Hello there, I am expert in PHP/wordpress. I can resolve that issue right now. so please share live details then let's fix asap. Thanks

$15USD 在1天里
(203条评论)
6.5
profydev

Hi i can fix foreach loop issue, i will fix this within 10 minutes, send message for start work right now. thank you.

$50 USD 在0天内
(50条评论)
6.0