Wordpress WooCommerce智能优惠券是从哪个项目生成的?

Wordpress WooCommerce智能优惠券是从哪个项目生成的?,wordpress,woocommerce,coupon,Wordpress,Woocommerce,Coupon,我正在为智能优惠券编写业务扩展(pdf打印) 现在我需要生成的优惠券(订单)和订单项之间的关系 例如,哪个订单项目生成了优惠券? 有没有办法从优惠券中获取订单商品id 使用以下代码获取优惠券: $coups=get_post_meta($order_id,'sc_coups_receiver_details',true)) 非常感谢我找到了一个解决方案,但我不得不将代码放在“woocommerce smart coups.php”文件中 第379行:扩展过滤器变量 add_filter( 'ge

我正在为智能优惠券编写业务扩展(pdf打印)

现在我需要生成的优惠券(订单)和订单项之间的关系

例如,哪个订单项目生成了优惠券? 有没有办法从优惠券中获取订单
商品id

使用以下代码获取优惠券:

$coups=get_post_meta($order_id,'sc_coups_receiver_details',true))


非常感谢

我找到了一个解决方案,但我不得不将代码放在“woocommerce smart coups.php”文件中

第379行:扩展过滤器变量

add_filter( 'generate_smart_coupon_action', array(  $this, 'generate_smart_coupon_action' ), 1, 10 );
第4783行:使用$item_id扩展变量

if( $this->is_coupon_amount_pick_from_product_price( array( $coupon_title ) ) ) {
                                            $email_to_credit[$receivers_emails[$coupon->id][0]][] = $coupon->id . ':' . $sc_called_credit_details[$item_id] . ':' . $item_id;
                                        } else {
                                            $email_to_credit[$receivers_emails[$coupon->id][0]][] = $coupon->id . ':' . $coupon->amount . ':' . $item_id;
                                        }
第4816行:从详细信息中获取$item\u id,并将其引用到“generate\u smart\u优惠券”方法

第5212行:将过滤器方法扩展到

public function generate_smart_coupon_action( $email, $amount, $order_id = '', $coupon = '', $discount_type = 'smart_coupon', $gift_certificate_receiver_name = '', $message_from_sender = '', $gift_certificate_sender_name = '', $gift_certificate_sender_email = '', $item_id = '' ) {
第5307行:将$item_id存储在post_meta中

update_post_meta( $smart_coupon_id, 'apply_before_tax', $apply_before_tax  );
                update_post_meta( $smart_coupon_id, 'free_shipping', $free_shipping );
                update_post_meta( $smart_coupon_id, 'product_categories', $product_categories  );
                update_post_meta( $smart_coupon_id, 'exclude_product_categories', $exclude_product_categories );
                update_post_meta( $smart_coupon_id, 'generated_from_order_id', $order_id );
                update_post_meta( $smart_coupon_id, 'generated_from_item_id', $item_id );
public function generate_smart_coupon_action( $email, $amount, $order_id = '', $coupon = '', $discount_type = 'smart_coupon', $gift_certificate_receiver_name = '', $message_from_sender = '', $gift_certificate_sender_name = '', $gift_certificate_sender_email = '', $item_id = '' ) {
update_post_meta( $smart_coupon_id, 'apply_before_tax', $apply_before_tax  );
                update_post_meta( $smart_coupon_id, 'free_shipping', $free_shipping );
                update_post_meta( $smart_coupon_id, 'product_categories', $product_categories  );
                update_post_meta( $smart_coupon_id, 'exclude_product_categories', $exclude_product_categories );
                update_post_meta( $smart_coupon_id, 'generated_from_order_id', $order_id );
                update_post_meta( $smart_coupon_id, 'generated_from_item_id', $item_id );