Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter kelvinthegerbil

    (@kelvinthegerbil)

    Apologies, the answer is in the export file.
    For those who scratch their heads wondering how to import the export… and wonder why it’s not under Details or Installation… these instructions are in a comment tag at the top of the export.

    To import this information into a WordPress site follow these steps:

    1. Log in to that site as an administrator.
    2. Go to Tools: Import in the WordPress admin panel.
    3. Install the “WordPress” importer from the list.
    4. Activate & Run Importer.
    5. Upload this file using the form provided on that page.
    6. You will first be asked to map the authors in this export file to users on the site. For each author, you may choose to map to an existing user on the site or to create a new user.
    7. WordPress will then import each of the posts, pages, comments, categories, etc. contained in this file into your site.

    Hi @studiosweb
    I think it is very setup specific and my “fix” didn’t fix the issue ??

    The latest attempt which has worked so far, is to comment out the two action calls that fire when woocommerce changes the order status to processing / complete. Add an extension that marks the order as complete automatically. And rely on the action call “woocommerce thank you” (or similar).

    I think that woocommerce is changing the order status multiple times in other areas which causes lots of codes and emails, and the bit in the plugin that marks a code as ‘sent’ just isn’t happening in our case.

    It’s working, but I’ve lost sight of the original code and flow now because of pulling it around to find a fix.

    The plugin does a great job in the most case, but I think it would be easier to just process and send the vouchers and mark the order as a new order status (like sent) instead of automatically on processing, complete, manually and on thanks.

    No idea if this solved it…. but at the moment I’m getting only one email per voucher and the only bit of the code that I changed was this in functions.php

    FROM

    $numc = 0;
    foreach ( $items as $item ) {
    	$product    = get_post_meta( $item['product_id'], 'giftcoupon' );
    	$giftcoupon = reset( $product );
    	if ( $giftcoupon == 'yes' ) {
    		$numc++;
    		if ( $item['qty'] > 1 ) {
    			$addsum = $item['qty'] - 1;
    			$numc   = $numc + $addsum;
    		}
    		$coupons['count'] = $numc;
    	}
    }

    TO

    $numc = 0;
    foreach ( $items as $item ) {
    	$product    = get_post_meta( $item['product_id'], 'giftcoupon' );
    	$giftcoupon = reset( $product );
    	if ( $giftcoupon == 'yes' ) {
    		$numc = $numc + $item['qty'];
    		$coupons['count'] = $numc;
    	}
    }

    I also removed the following from the mail.php file so that it only sent emails for ‘processing’ status and not ‘completed’ status in WooCommerce

    add_action( 'woocommerce_order_status_completed',.....

    I should also say that this is a multisite install, if that plays a hand in causing this!

    Hi @studiosweb
    do you have a solution for the multiple emails/codes being sent?
    Thank you

    Same issue here, but on a multisite installation.
    The fix was to removed the multisite id from the sql that creates the ‘woocommerce_gift_coupon’ table on install.

    $sql = 'CREATE TABLE IF NOT EXISTS $table( etc, etc, etc...';
    Has the line below.
    FOREIGN KEY (id_user) REFERENCES ' . $wpdb->prefix . 'users(ID)

    However $wpdb->prefix has multisite ID (i.e. ab_12_) which makes it look for ab_12_users to create the foreign key restraint. But Multisite WordPress users a single table for users (in the examples’ case ab_users) so hard-code this, or run the SQL separately to create the table and hey presto!

    I hope this also helps someone.

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