• Resolved ryantcarter

    (@ryantcarter)


    Hey Guys,

    I’m trying to get an order to populate in woocommerce when an s2member payment is received. I’m 90% of the way there. When a coupon is entered via s2member i’ve managed to get woocommerce to recognise it and add the relevant discount to the order.

    Trouble is, when there’s no discount added. The order doesn’t come through to woocommerce.

    Here’s the PHP i’ve got running this part of it, obviously it’s pulling in the vars from further up the script.

    Can anyone see anything glaringly obvious I’m doing wrong?

    $order = wc_create_order();
        $order->add_product(get_product($tier), 1);
        $order->set_address($address, 'billing');
        $order->set_address($address, 'shipping');
        if ($coupon_code == 'code135' || $coupon_code == 'code235' || $coupon_code == 'code335')
        		{
    	    	$order->add_coupon($coupon_code, 6.65);
    			$order->set_total(6.65, 'order_discount');
    			}
    	$order->calculate_totals();
    	$order->payment_complete();

    https://ww.wp.xz.cn/plugins/s2member/

Viewing 1 replies (of 1 total)
  • Thread Starter ryantcarter

    (@ryantcarter)

    As a work around to this, I’ve piped a fixed character through the URL string before the replacement code, this means I’ve always got a value to reference.

Viewing 1 replies (of 1 total)

The topic ‘Payment Notification API’ is closed to new replies.