Forum Replies Created

Viewing 15 replies - 1 through 15 (of 19 total)
  • Hi Markzuckerbels,
    I have solved it by writing small Javascript code, So after click on the image (.post-ratings img) from the url page-listing-votes will redirect to url thanks-page. You may need to change the urls as you want.

            // Redirect to page after Voting
            $('.post-ratings img').click(function() {
                $.ajax({  
                    url: 'page-listing-votes', 
                    success: function(data){
                      window.location.href = "thanks-page";                    
                    }
                });
            });

    Hi Jan,
    Thanks for your answer. Sorry I meant wp_insert_term
    https://codex.wordpress.org/Function_Reference/wp_insert_term

    I found another way to insert and update term by using $wpdb->query and $wpdb->update and I think that is much powerfull.

    https://code.tutsplus.com/articles/advanced-wordpress-queries-part-3–wp-21366

    Thanks Steven for your answer 🙂

    Yes I saw that, and thats I am asking for how to use get_sites with custom parameters. If we have a site with options. And we want to list all sites that using specific options.
    options built with acf.

    malasaad82

    (@malasaad82)

    Thank you

    malasaad82

    (@malasaad82)

    No problem 🙂 thanks for your help too

    malasaad82

    (@malasaad82)

    Hi,
    Yes I have fixed it.I have created custom fields for order (update_post_meta) and then I added it there by using Add field. Its a bit custom becoz I used subscription plugin with woo-commerce.

    Here is the code, hope it will help who need 🙂

    
    add_action( 'woocommerce_renewal_order_payment_complete', 'add_custom_fields_order_data',  10, 2 );
    add_action( 'woocommerce_thankyou', 'add_custom_fields_order_data',  10, 2 );
    function add_custom_fields_order_data( $order_id ){
    	
    	// If Current order is subscription renewal order
    	if ( wcs_order_contains_subscription( $order_id, 'renewal' ) ) {
    	    // Set meta to 1 for renewal orders
    	    update_post_meta( $order_id, '_wc_acof_4', 1);   	 
    	    update_post_meta( $order_id, '_wc_acof_5', 1);   	 
    	    update_post_meta( $order_id, '_wc_acof_6', 1);   	 		
    	}else{
    	    update_post_meta( $order_id, '_wc_acof_4', 0);   	 
    	    update_post_meta( $order_id, '_wc_acof_5', 0);   	 
    	    update_post_meta( $order_id, '_wc_acof_6', 0);   	 				
    	}
    
    	// If Current order is subscription parent order = The first order from customer.
    	if ( wcs_order_contains_subscription( $order_id, 'parent' ) ) {
    		$products_to_check = array('2755','2678','2672');	// Check specific products by id
    	    $customer_bought = array();
    
    		$get_order = wc_get_order( $order_id );
    		$items = $get_order->get_items();
    		$user_id = $get_order->get_user_id();
    		$user_email = $get_order->get_billing_email();
    
    		// Current order
    		// Save current products from current order.
    		foreach ( $items as $item ) {
    			$order_product_ids[] = $item['product_id'];
    		}
    		// Remove other products from order_product and keep just ones to check 2755,2678,2672
    		foreach ($order_product_ids as $key => $order_product_id) {
    			if(!in_array($order_product_id, $products_to_check)) {
    	            unset($order_product_ids[$key]);
    	        }	    
    		}
     		
     		// Old orders
    	    // Get all customer orders with meta_key _wc_acof_2 = 1
    	    $customer_orders = wc_get_orders( array(
    		    'limit'    	=> -1,
    		    'status'   	=> array( 'wc-completed','wc-processing' ),
    		    'customer' 	=> $user_id,
    		    'email'    	=> $user_email,
    		    'exclude' 	=> array( $order_id ),	// Exclude the current order.
    			'meta_key'		=> '_wc_acof_1',	// use one meta _wc_acof_2 as all have same value. _wc_acof_2,_wc_acof_3,_wc_acof_4
    			'meta_value'	=> '1'
    		));
    	    if(count($customer_orders) > 0) {
    			foreach($customer_orders as $customer_order) {
    				//Check only if old order is Subscription type.
    				if ( wcs_order_contains_subscription( $customer_order->ID, 'parent' )  ) {	
    		 			$c_order = wc_get_order($customer_order->ID);
    		 			
    					$c_items = $c_order->get_items();
    					foreach ( $c_items as $c_item ) {
    		             	if(in_array($c_item['product_id'], $order_product_ids)) {
    			                $customer_bought[] = $c_item['product_id'];
    		             	}		
    					}
    				}
    	 		}
    	    }	
    	     
    	    // Already bought same subscription product. flag field = 0
    	    if(!empty($customer_bought)){
    	    	update_post_meta( $order_id, '_wc_acof_1', 0);   	 
    	    	update_post_meta( $order_id, '_wc_acof_2', 0);   	 
    	    	update_post_meta( $order_id, '_wc_acof_3', 0);   	 
    	    }else{
    	    	// Did not buy this subscription before.  flag field = 1
    	    	update_post_meta( $order_id, '_wc_acof_1', 1 );   
    	    	update_post_meta( $order_id, '_wc_acof_2', 1 );   
    	    	update_post_meta( $order_id, '_wc_acof_3', 1 );   
    	    }
    
    	}else{
    		// Not Subscription Product. flag field = 0
    		update_post_meta( $order_id, '_wc_acof_1', 0 );   
    		update_post_meta( $order_id, '_wc_acof_2', 0 );   
    		update_post_meta( $order_id, '_wc_acof_3', 0 );   
    	}
    }

    Hi DionDesgins,
    I have macOS high sierra and I am using MAMP Pro 4.2 with PHP 7.1.6
    Its back working fine just without doning any changes.

    Thank you Rajan for your answer. Its fixed alone without change anything. I think it was something from WordPress server.

    Thank you will try to do it 🙂

    Thank you

    Hi Alex,
    Thank you for your answer, I have tried change your code for cod and its like this: but not sure how to do that with more than one product. should I repeat all for each one?

    add_filter('woe_get_order_value_cod_super', function ($value,$order,$field) {
    	$get_order = wc_get_order( $order->id );
    	$items = $get_order->get_items();
    	foreach ( $items as $item ) {
    		if('2675' == $item->get_product_id()){
    			return $item->get_quantity();
    		}
    	}	
    },10, 3);
    add_filter('woe_get_order_fields', function ($fields) {
    	//add to field list
    	$fields['cod_super'] = array( 'label' => 'Product Super', 'colname' => 'Product Super', 'checked' => 1 );
    	return $fields;
    });

    Another thing,,, Its not showing result if its used in custom field.

    Hi Alx359
    I think you need to print the postid as following:
    echo do_shortcode('[WPCR_SHOW POSTID="'.$post->ID.'" NUM="5" PAGINATE="1" PERPAGE="5" SHOWFORM="1" HIDEREVIEWS="0" HIDERESPONSE="0" SNIPPET="" MORE="" HIDECUSTOM="0" ]');

    • This reply was modified 2 years, 3 months ago by malasaad82.

    Hi,
    I will do another test tmw. I will install the plugin in fresh WP copy.. And I want to ask , What is the db tables they related with the plugin…

Viewing 15 replies - 1 through 15 (of 19 total)