jeudi 29 octobre 2015

I want to cancel old Subscriptions when new Subscriptions will place in woocommerce?

add_action('woocommerce_payment_complete', 'custom_process_order', 10, 1);
    function custom_process_order($order_id) {
        $order = new WC_Order( $order_id );
        $myuser_id = (int)$order->user_id;
        $user_info = get_userdata($myuser_id);
        $items = $order->get_items();
        foreach ($items as $item) {

            if ($item['product_id']==24) {
              // Do something clever
            }
        }
        return $order_id;
    }

i am trying to add woocommerce action hook "woocommerce_payment_complete" to get old subscriptions detail for cancellation , but it doesn't work .

Basically i want the different kind of functionality , let me explain for ex: suppose a customer subscribe $10 product for month but customer added new subscription before month , so I want to cancel old one and add new subscription .

If anyone could suggest me the simplest way to achieve this woocommerce functionality.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire