Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter sarwara

    (@sarwara)

    solved

    Thread Starter sarwara

    (@sarwara)

    hi… my issue has been solved. i have replaced above code with code below:
    add_action( ‘woocommerce_email_before_order_table’, ‘add_order_email_instructions’, 10, 2 );

    function add_order_email_instructions( $order, $sent_to_admin ) {

    if ( apply_filters( ‘woocommerce_payment_complete_reduce_order_stock’, ! get_post_meta( $order, ‘_order_stock_reduced’, true ), $order) ) {

    if ( ‘processing’ == $order->status ) {
    if ( count( $order->get_items() ) > 0 ) {
    echo ‘<table cellpadding=”6″ color: #696969; style=”border-collapse: collapse; width: 100%; font-family: “Helvetica Neue”, Helvetica, Roboto, Arial, sans-serif;” >
    <tr>
    <th style=”text-align:left; border:1px solid #9f9f9f;” >Product</th>
    <th style=”text-align:left; border:1px solid #9f9f9f;” >Quantity</th>
    <th style=”text-align:left; border:1px solid #9f9f9f;” >voucher Code</th></tr>’;
    $items = $order->get_items() ;
    foreach( $items as $item ) {
    $product_id = $item[‘product_id’];
    $product_name = $item[‘name’];
    $product_qty = $item[‘qty’];
    $v_codes = get_post_meta($product_id, ‘_voucher_codes_field’, true);
    $v_codes_array = explode(‘,’, $v_codes );
    echo ‘<tr>
    <td style=”text-align:left; border:1px solid #9f9f9f;” >’.$product_name.'</td>
    <td style=”text-align:left; border:1px solid #9f9f9f;” >’.$product_qty.'</td>
    <td style=”text-align:left; border:1px solid #9f9f9f;” >’;
    if($product_qty > 1){
    $v_qty = get_post_meta($product_id, ‘_stock’, true);
    $v_qty = $v_qty + $product_qty;
    for($i = 1; $i <= $product_qty; $i++){
    $pointer = $v_qty – $i;
    echo ‘code-‘. $i.’ : ‘.$v_codes_array[$pointer]. ‘ : ‘.$pointer .’
    ‘;
    }
    }else if($product_qty == 1){
    $v_qty = get_post_meta($product_id, ‘_stock’, true);
    echo ‘code :’. $v_codes_array[$v_qty]. ‘ : ‘.$v_qty;
    }

    echo ‘</td></tr>’;
    }
    echo ‘</table>’;

    }
    $order->reduce_order_stock();
    }
    }
    }

    but i have new problem now.. which is

    my product stock is being reduced twice.
    any solution pls.

    Thread Starter sarwara

    (@sarwara)

    Issue has been solved by simply adding the html form for import with custom button add hook.

Viewing 3 replies - 1 through 3 (of 3 total)