将作者电子邮件地址附加到paypal的产品 - 代码已停止工作

The following code has been working beautifully for my Woocommerce Wordpress website, but after the most recent update it has stopped working.

Anyone have any insight into what may be causing the code to stop working?

Any insight or help will be such big help as this is a key feature of my site.

Thanks!

===================================================================
     *
     * Function to enable item-specific paypal email addresses
     *
     * ================================================================ */
    function find_alt_paypal_emails() {
        global $woocommerce;
        // loop over the items in the cart
        foreach ( $woocommerce->cart->cart_contents as $item ) {
            // check to see if any of them has the 'paypal_email' meta value
            $override_email = get_post_meta($item['product_id'], 'paypal_email', true);
            // if there is an override val, build an array of each item name and the
            // paypal email associated with that item
            if ( ! empty( $override_email ) ) {
                $paypal_override = array(
                    'item_title' => $item['data']->post->post_title,
                    'email' => $override_email
                    );
                $paypal_overrides[] = $paypal_override;
                // error_log(print_r($paypal_overrides,true));
            }
        }
        // if there are override emails indicated
        if ( ! empty( $paypal_overrides ) ) {
            // loop through and build an error message to warn the user of multiple payees
            if ( count( $paypal_overrides ) > 1 ) {
                $error_list = '';
                foreach ( $paypal_overrides as $override ) {
                    $error_list .= $override['item_title'] . ' → ' . $override['email'] . ', ';
                }
                $error_list = rtrim($error_list, ', ');
                $woocommerce->add_error( __( 'The following items send payment to different '
                    . 'PayPal Users, please place separate orders: (' . $error_list . ')', 'woocommerce' ) );
            } else {
                return $paypal_overrides[0]['email'];
            }
        }
    }
    add_action( 'woocommerce_after_cart_contents', 'find_alt_paypal_emails' );
    add_action( 'woocommerce_after_checkout_form', 'find_alt_paypal_emails' );
    add_action( 'woocommerce_after_order_total', 'find_alt_paypal_emails' );
    /*$paypal_args = apply_filters( 'woocommerce_paypal_args', $paypal_args );*/
    // Hook in
    add_filter( 'woocommerce_paypal_args' , 'custom_override_paypal_email' );
    // Our hooked in function is passed via the filter!
    function custom_override_paypal_email( $paypal_args ) {
        $alt_email = find_alt_paypal_emails();
        error_log(print_r($alt_email,true));
        if ( empty( $alt_email ) ) {
            return $paypal_args;
        }
        $paypal_args['business'] = find_alt_paypal_emails();
        print_r( $paypal_args['business'],true );
        return $paypal_args;
    }
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐