Forum Replies Created

Viewing 15 replies - 31 through 45 (of 55 total)
  • hi Clearing all the fields in the notification and adding them in again meant i could get the text again as per this post:

    Thanks

    Andi

    In the main file. Is it supposed to include notifications twice?

    // Include our single notification object
    require_once( NF_PLUGIN_DIR . ‘classes/notification.php’ );
    // Include our notifications object
    require_once( NF_PLUGIN_DIR . ‘classes/notifications.php’ );

    I thought a require_once would cause a fatal???

    Hi there,

    One site I have is receiving the emails, but no information in the body.
    The csv has the data.

    Tried Plain Text and HTML versions.
    Tried submit via ajax, and tried on and off
    Checked the logs nothing.
    Tried deactivating the plugin and re-activating again.

    So it doesn’t work at all. As there is no error in the log one could assume that it would take a while to drill down into it.

    Thanks

    Andi

    Ok I just tested the above.

    Works fine and fixes the errors from the W3C and still works if you save the form with AJAX.

    Maybe Ninja Forms would take some of these fixes and integrate them into the original functions.

    Thanks

    Andi

    Ok the way to solve issue 2:
    Put the Ninja form url into the HEAD

    remove_action( 'ninja_forms_display_css', 'ninja_forms_display_css');
    add_action( 'init', 'ninja_forms_display_css_amend', 10, 2 );
    function ninja_forms_display_css_amend(){
    	wp_enqueue_style( 'regencykitchens-style-ninja-a', NINJA_FORMS_URL .'css/ninja-forms-display.css' );
    	wp_enqueue_style( 'regencykitchens-style-ninja-b', NINJA_FORMS_URL .'css/qtip.css' );
    	wp_enqueue_style( 'regencykitchens-style-ninja-c', NINJA_FORMS_URL .'css/jquery.rating.css' );
    }

    The JS can be left where it is.

    We can also resolve the other issues in a similar way:

    function ninja_forms_register_display_open_form_tag_override($form_id) {
    	/// 1 - remove and add form open tag and make sure the URL is the same
    	remove_action('ninja_forms_display_open_form_tag', 'ninja_forms_display_open_form_tag');
    	add_action('ninja_forms_display_open_form_tag', 'ninja_forms_display_open_form_tag_amend');
    
    }
    add_action( 'init', 'ninja_forms_register_display_open_form_tag_override' );
    
    function ninja_forms_display_open_form_tag_amend( $form_id ) {
    
    	/// We need to get the post in order to know which page we are on
    	global $post;
    
    	$form_row = ninja_forms_get_form_by_id( $form_id );
    
    	if ( isset ( $form_row['data']['ajax'] ) )
    		$ajax = $form_row['data']['ajax'];
    	else
    		$ajax = 0;
    
    	if ( $ajax == 1 ) {
    		if( is_ssl() ) {
    			$url = admin_url( 'admin-ajax.php', 'https' );
    		}
    		else {
    			$url = admin_url( 'admin-ajax.php', 'http' );
    		}
    		$url = apply_filters( 'ninja_forms_ajax_url', $url, $form_id );
    		$url = add_query_arg( 'action', 'ninja_forms_ajax_submit', $url );
    		//$url = add_query_arg('action', 'test', $url);
    	} else {
    		/// This was added to make the form is posted back to the same page. - THE ORIGNAL SCRIPT is just a blank string
    		$url = get_permalink( $post->ID );//'';
    	}
    
    	$display = 1;
    
    	$display = apply_filters( 'ninja_forms_display_form_visibility', $display, $form_id );
    
    	if ( $display != 1 )
    		$hide_class = " ninja-forms-no-display";
    	else
    		$hide_class = "";
    
    	$form_class = '';
    
    	$form_class = apply_filters( 'ninja_forms_form_class', $form_class, $form_id );
    
    	if ( ! empty( $form_class ) )
    		$form_class = ' ' . $form_class;
    
    	?>
    	<form id="ninja_forms_form_<?php echo $form_id;?>" enctype="multipart/form-data" method="post" name="" action="<?php echo $url;?>" class="ninja-forms-form<?php echo $form_class;?><?php echo $hide_class;?>">
    
    	<?php
    
    }

    This then leaves the issue in the post which can also be amended.
    However I do not yet know the reason for having the rel as the field ID – it may be to do with how the form saves, so doing this below may/may not affect it (Ajax or no)

    SO – change rel to data binding attribute…

    /// 2 - Swap the rel attribute with a data binding attribute - This for no ajax forms
    remove_action('init','ninja_forms_register_field_textbox' );
    add_action( 'init', 'ninja_forms_register_field_textbox_amend' );
    remove_action('init','ninja_forms_register_field_submit' );
    add_action('init', 'ninja_forms_register_field_submit_amend');
    
    function ninja_forms_register_field_textbox_amend(){
    	$args = array(
    		'name' => __( 'Textbox', 'ninja-forms' ),
    		'sidebar' => 'template_fields',
    		'edit_function' => 'ninja_forms_field_text_edit',
    		'edit_options' => array(
    			array(
    				'type' => 'checkbox',
    				'name' => 'datepicker',
    				'label' => __( 'Datepicker', 'ninja-forms' ),
    			),
    			array(
    				'type' => 'checkbox',
    				'name' => 'email',
    				'label' => __( 'Validate as an email address? (Field must be required)', 'ninja-forms' ),
    			),
    			// array(
    			// 	'type' => 'checkbox',
    			// 	'name' => 'send_email',
    			// 	'label' => __( 'Send a response email to this email address?', 'ninja-forms' ),
    			// ),
    			// array(
    			// 	'type' => 'checkbox',
    			// 	'name' => 'from_email',
    			// 	'label' => __( 'Use this as the "From" email address for Administrative recipients of this form?', 'ninja-forms' ),
    			// ),
    			// array(
    			// 	'type' => 'checkbox',
    			// 	'name' => 'replyto_email',
    			// 	'label' => __( 'Use this email address as the Reply-To address?', 'ninja-forms' ),
    			// ),
    			array(
    				'type' => 'hidden',
    				'name' => 'first_name',
    			),
    			array(
    				'type' => 'hidden',
    				'name' => 'last_name',
    			),
    			// array(
    			// 	'type' => 'checkbox',
    			// 	'name' => 'from_name',
    			// 	'label' => __( 'Use this as the "From" and Reply-To email name for Administrative recipients of this form?', 'ninja-forms' ),
    			// ),
    			array(
    				'type' => 'hidden',
    				'name' => 'user_address_1',
    			),
    			array(
    				'type' => 'hidden',
    				'name' => 'user_address_2',
    			),
    			array(
    				'type' => 'hidden',
    				'name' => 'user_city',
    			),
    			array(
    				'type' => 'hidden',
    				'name' => 'user_zip',
    			),
    			array(
    				'type' => 'hidden',
    				'name' => 'user_phone',
    			),
    			array(
    				'type' => 'hidden',
    				'name' => 'user_email',
    			),
    			array(
    				'type' => 'hidden',
    				'name' => 'user_info_field_group',
    				'default' => 1,
    			),
    			array(
    				'type' => 'checkbox',
    				'label' => __( 'This is the user\'s state', 'ninja-forms' ),
    				'name' => 'user_state',
    			),
    		),
    		'display_function' => 'ninja_forms_field_text_display_amend', ///// <--- THIS IS WHAT WE HAVE TO AMEND I put a suffix as _amend (the function is below this)
    		'save_function' => '',
    		'group' => 'standard_fields',
    		'edit_label' => true,
    		'edit_label_pos' => true,
    		'edit_req' => true,
    		'edit_custom_class' => true,
    		'edit_help' => true,
    		'edit_desc' => true,
    		'edit_meta' => false,
    		'edit_conditional' => true,
    		'conditional' => array(
    			'value' => array(
    				'type' => 'text',
    			),
    		),
    		'pre_process' => 'ninja_forms_field_text_pre_process',
    		'edit_sub_value' => 'nf_field_text_edit_sub_value',
    		'sub_table_value' => 'nf_field_text_sub_table_value',
    	);
    
    	ninja_forms_register_field( '_text', $args );
    }
    
    function ninja_forms_field_text_display_amend( $field_id, $data, $form_id = '' ){
    	global $current_user;
    	$field_class = ninja_forms_get_field_class( $field_id, $form_id );
    
    	if ( isset( $data['email'] ) && $data['email'] == 1 ) {
    		$field_class .= ' email';
    	}
    
    	if(isset($data['default_value'])){
    		$default_value = $data['default_value'];
    	}else{
    		$default_value = '';
    	}
    
    	if(isset($data['label_pos'])){
    		$label_pos = $data['label_pos'];
    	}else{
    		$label_pos = "left";
    	}
    
    	if(isset($data['label'])){
    		$label = $data['label'];
    	}else{
    		$label = '';
    	}
    
    	if( isset( $data['mask'] ) ){
    		$mask = $data['mask'];
    	}else{
    		$mask = '';
    	}	
    
    	if( isset( $data['input_limit'] ) ){
    		$input_limit = $data['input_limit'];
    	}else{
    		$input_limit = '';
    	}
    
    	if( isset( $data['input_limit_type'] ) ){
    		$input_limit_type = $data['input_limit_type'];
    	}else{
    		$input_limit_type = '';
    	}
    
    	if( isset( $data['input_limit_msg'] ) ){
    		$input_limit_msg = $data['input_limit_msg'];
    	}else{
    		$input_limit_msg = '';
    	}
    
    	switch( $mask ){
    		case '':
    			$mask_class = '';
    			break;
    		case 'date':
    			$mask_class = 'ninja-forms-date';
    			break;
    		case 'currency':
    			$mask_class =  'ninja-forms-currency';
    			break;
    		default:
    			$mask_class = 'ninja-forms-mask';
    			break;
    	}
    
    	if( isset( $data['datepicker'] ) AND $data['datepicker'] == 1 ){
    		$mask_class = 'ninja-forms-datepicker';
    	}
    
    	?>
    	<input id="ninja_forms_field_<?php echo $field_id;?>" data-mask="<?php echo $mask;?>" data-input-limit="<?php echo $input_limit;?>" data-input-limit-type="<?php echo $input_limit_type;?>" data-input-limit-msg="<?php echo $input_limit_msg;?>" name="ninja_forms_field_<?php echo $field_id;?>" type="text" class="<?php echo $field_class;?> <?php echo $mask_class;?>" value="<?php echo $default_value;?>" data-field-id="<?php echo $field_id;?>" /> <!-- !!!!!!! HERE I CHANGED rel= to data-field-id -->
    	<?php
    
    }
    
    function ninja_forms_register_field_submit_amend(){
    	$args = array(
    		'name' => __( 'Submit', 'ninja-forms' ),
    		'display_function' => 'ninja_forms_field_submit_display_amend',
    		'group' => 'standard_fields',
    		'edit_label' => true,
    		'edit_label_pos' => false,
    		'edit_req' => false,
    		'edit_custom_class' => true,
    		'edit_help' => true,
    		'edit_meta' => false,
    		'sidebar' => 'template_fields',
    		'display_label' => false,
    		'edit_conditional' => true,
    		'conditional' => array(
    			'value' => array(
    				'type' => 'text',
    			),
    		),
    		'process_field' => false,
    		'limit' => 1,
    	);
    
    	ninja_forms_register_field('_submit', $args);
    }
    
    function ninja_forms_field_submit_display_amend( $field_id, $data, $form_id = '' ){
    	global $ninja_forms_loading, $ninja_forms_processing;
    
    	if ( isset ( $ninja_forms_loading ) ) {
    		$form_id = $ninja_forms_loading->get_form_ID();
    	} else {
    		$form_id = $ninja_forms_processing->get_form_ID();
    	}
    
    	if(isset($data['show_field'])){
    		$show_field = $data['show_field'];
    	}else{
    		$show_field = true;
    	}
    
    	$field_class = ninja_forms_get_field_class( $field_id, $form_id );
    	if(isset($data['label']) AND $data['label'] != ''){
    		$label = $data['label'];
    	}else{
    		$label = 'Submit';
    	}
    	$plugin_settings = nf_get_settings();
    	if ( isset ( $plugin_settings['process_label'] ) ) {
    		$processing_msg = $plugin_settings['process_label'];
    	}
    	?>
    	<div id="nf_submit_<?php echo $form_id; ?>">
    		<input type="submit" name="_ninja_forms_field_<?php echo $field_id;?>" class="<?php echo $field_class;?>" id="ninja_forms_field_<?php echo $field_id;?>" value="<?php echo $label;?>" data-field-id="<?php echo $field_id;?>" >
    	</div>
    	<div id="nf_processing_<?php echo $form_id; ?>" style="display:none;">
    		<input type="submit" name="" class="<?php echo $field_class; ?>" value="<?php echo $processing_msg; ?>" data-field-id="<?php echo $field_id;?>" disabled>
    	</div>
    	<?php
    
    }

    Ok well I don’t get it as I tried deactivating the plugins and changing the theme to a standard one. If the shortcode is on the page then the scripts are included then, which would make sense.

    We can remove actions and add them again.
    The other option I’m guessing is to un-enque the CSS only and add theme the theme itself and add them there.

    Actually checking the file the scripts are suppost to include in the head as the enqeue_script attribute to load in the foot is not present. So another plugin must be interfering.

    hi Got a few validation errors with Ninja Forms because I created a quick contact form on the front page.

    First:
    When you are not submitting the form with Ajax, the action attribute is missing a value. This value should be set to url of the page you are on at least.

    Second:
    ninja forms output links to CSS and all the other stuff of the plugin in the <body> of the website and should really be in the <head>. Although with HTML5 is deemed ok, the 3WC validation does not like this. The W3C Validator has not caught up with everything just yet.
    So trigger the plugin to be higher up the scale.

    Third:
    As above… Bad value 9 for attribute rel on element input: The string 9 is not an absolute URL.
    …submit” name=”” class=”ninja-forms-field ” value=”Processing” rel=”9″ disabled>

    The same goes for any input field using the rel attribute in this way.
    Why not create an HTML5 data binding attribute for this and use this instead. Like data-field-id=”9″ you can use this databinding to still send the same information via Ajax instead of using the rel.

    Thanks

    Andi

    Thread Starter Andi Lee Davis

    (@andi-lee-davis)

    Ok figured this one out.

    There is a header action that clears the cart. We needed to add some more statuses to the array so that it ignores it.

    1st remove the action and then add your own method.

    function st_wc_clear_cart_after_payment( $methods ) {
        global $wp, $woocommerce;
    
        if ( ! empty( $wp->query_vars['order-received'] ) ) {
    
            $order_id = absint( $wp->query_vars['order-received'] );
    
            if ( isset( $_GET['key'] ) )
                $order_key = $_GET['key'];
            else
                $order_key = '';
    
            if ( $order_id > 0 ) {
                $order = wc_get_order( $order_id );
    
                if ( $order->order_key == $order_key ) {
                   WC()->cart->empty_cart();
                }
            }
    
        }
    
        if ( WC()->session->order_awaiting_payment > 0 ) {
    
            $order = wc_get_order( WC()->session->order_awaiting_payment );
    
            if ( $order->id > 0 ) {
                // If the order has not failed, or is not pending, the order must have gone through
                if ( ! $order->has_status( array( 'failed', 'pending','pending-st-cleared-funds','on-hold' ) ) ) { ///// <- add your custom status here....
                    WC()->cart->empty_cart();
                }
             }
        }
    Thread Starter Andi Lee Davis

    (@andi-lee-davis)

    Ok one step closer

    this function… runs and checks if an order is received or not.
    in includes/wc-cart-functions.php
    wc_clear_cart_after_payment()

    not sure…

    Thread Starter Andi Lee Davis

    (@andi-lee-davis)

    Hi there, Yeah I solved it by using the xfn field already in the wrodpress section. Thanks for your information and well done on your plugin.

    Its a long time back but using this variable WP_PLUGIN_DIR resolves that initial issue.

    Thanks

    Andi

    Thread Starter Andi Lee Davis

    (@andi-lee-davis)

    ok, by running the insert of categories after the insert post it seemed to work fine.

    This is the updated code so far, which works but I think the thing here to note is the

    private function setEKMStock($object, $url, $apiKey, $clientID) {
    
    		global $wpdb;
    		$count = 0;
    		$parser = new ArrayObject();
    
    		/*$xml_post_string = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="https://www.w3.org/2001/XMLSchema" xmlns:soap="https://schemas.xmlsoap.org/soap/envelope/"><soap:Body>';
    
    		$xml_post_string .= '<SetProductStock xmlns="https://publicapi.ekmpowershop.com/"><SetProductStockRequest><APIKey>' . $apiKey . '</APIKey>';*/
    
    		// Post thumbnail support
    		if ( ! current_theme_supports( 'post-thumbnails', 'product' ) ) {
    			add_theme_support( 'post-thumbnails' );
    			remove_post_type_support( 'post', 'thumbnail' );
    			remove_post_type_support( 'page', 'thumbnail' );
    		} else {
    			add_post_type_support( 'product', 'thumbnail' );
    		}
    
    		// Make sure that this file is included, as wp_generate_attachment_metadata() depends on it.
    		require_once( ABSPATH . 'wp-admin/includes/image.php' );
    		require_once( ABSPATH . 'wp-admin/includes/file.php' );
    		require_once( ABSPATH . 'wp-admin/includes/media.php' );
    
    		// Add image sizes
    		$shop_thumbnail = wc_get_image_size( 'shop_thumbnail' );
    		$shop_catalog	= wc_get_image_size( 'shop_catalog' );
    		$shop_single	= wc_get_image_size( 'shop_single' );
    		///var_dump($object[0]);
    		foreach($object as $key => $value){
    
    			//// check if update or insert post
    			$name = $value['Name'];
    			$sku = $value['SKU'];
    			$shortDescription = $value['ShortDescription'];
    			$filename = $value['Photo'];
    			$price = $value['Price'];
    			$packQty = $value['PackQty'];
    			$stock = $value['Stock'];
    			$the_categories = $value['Category'];
    			$post_categories = array();
    
    			$pattern = '/?([A-Za-z]+)/';
    			preg_match($pattern, substr($sku, 0), $matches);
    			$size = (!empty($matches)) ? '-' . $matches[0] : NULL;
    			$post_name = sanitize_title_with_dashes(trim(strtolower($name . $size)));
    
    			switch($size) {
    				case '-XS':
    					$textSize = 'Extra Small';
    					break;
    				case '-S':
    					$textSize = 'Small';
    					break;
    				case '-M':
    					$textSize = 'Medium';
    					break;
    				case '-L':
    					$textSize = 'Large';
    					break;
    				case '-XL':
    					$textSize = 'Extra Large';
    					break;
    				default:
    					$textSize = NULL;
    			}
    
    			$query = $wpdb->prepare('SELECT ID FROM ' . $wpdb->posts . ' WHERE post_name = %s', $post_name);
    			$cID = $wpdb->get_var( $query );			
    
    			///var_dump($cID);
    
    			$postData = array(
    				  ///'post_content'   => $value['ShortDescription'], // The full text of the post.
    				  'post_name'      => $post_name, // The name (slug) for your post
    				  'post_title'     => $name . ' ' . $textSize, // The title of your post.
    				  'post_status'    => 'publish', // Default 'draft'.
    				  'post_type'      => 'product', // Default 'post'.
    				  'post_author'    => 1, // The user ID number of the author. Default is the current user ID.
    				  'ping_status'    => 'closed', // Pingbacks or trackbacks allowed. Default is the option 'default_ping_status'.
    				  ///'post_parent'    => [ <post ID> ] // Sets the parent of the new post, if any. Default 0.
    				  ///'menu_order'     => [ <order> ] // If new post is a page, sets the order in which it should appear in supported menus. Default 0.
    				  ///'to_ping'        => // Space or carriage return-separated list of URLs to ping. Default empty string.
    				  ///'pinged'         => // Space or carriage return-separated list of URLs that have been pinged. Default empty string.
    				  ////'post_password'  => [ <string> ] // Password for post, if any. Default empty string.
    				  ///'guid'           => // Skip this and let WordPress handle it, usually.
    				  ///'post_content_filtered' => // Skip this and let WordPress handle it, usually.
    				  'post_excerpt'   => $shortDescription, // For all your post excerpt needs.
    				  'post_date'      => date('Y-m-d H:i:s'), // The time post was made.
    				  'post_date_gmt'  => date('Y-m-d H:i:s'), // The time post was made, in GMT.
    				  'comment_status' => 'open', // Default is the option 'default_comment_status', or 'closed'.
    				  ///'post_category'  => array($post_categories) // Default empty. --- DOESN'T WORK
    				  ///'tags_input'     => [ '<tag>, <tag>, ...' | array ] // Default empty.
    					/// 'tax_input'      => array($post_categories) // For custom taxonomies. Default empty. --- DOESN'T WORK
    				  ///'page_template'  => [ <string> ] // Requires name of template file, eg template.php. Default empty.
    			);
    
    			if (empty($cID) ) {
    
    				///insert data
    				$cID = wp_insert_post($postData);
    
    				//// Update the other meta data
    				update_post_meta($cID, 'total_sales', '0'); /// If new
    				//// Handle files from folder and attach to the product
    
    				// The ID of the post this attachment is for.
    				$parent_post_id = $cID;
    
    				// Get the path to the upload directory.
    				$wp_upload_dir = wp_upload_dir();
    
    				// Check the type of tile. We'll use this as the 'post_mime_type'.
    				$filetype = wp_check_filetype( $wp_upload_dir['baseurl'] . '/AllProducts/' . basename( $filename ), NULL );
    
    				//// check file exists and process
    				$theFile = trim($wp_upload_dir['basedir'] . '/AllProducts/' . basename( $filename ));
    				if(file_exists($theFile)){
    					// Prepare an array of post data for the attachment.
    					$attachment = array(
    						'guid'           => trim($wp_upload_dir['baseurl'] . '/AllProducts/' . basename( $filename ) ),
    						'post_mime_type' => $filetype['type'],
    						'post_title'     => preg_replace( '/\.[^.]+$/', '', basename( $filename ) ),
    						'post_content'   => '',
    						'post_status'    => 'inherit'
    					);
    
    					// Insert the attachment.
    					$attach_id = wp_insert_attachment( $attachment, trim($wp_upload_dir['baseurl'] . '/AllProducts/' . basename( $filename )), $parent_post_id );
    
    					// Generate the metadata for the attachment, and update the database record.
    					$attach_data = wp_generate_attachment_metadata( $attach_id, $theFile );
    					wp_update_attachment_metadata( $attach_id, $attach_data );
    					// Finally! set our post thumbnail
            			update_post_meta( $parent_post_id, '_thumbnail_id', $attach_id );
    				}
    
    			} else {
    				///update data
    				$postData = array('ID'=>$cID) + $postData;
    				var_dump($postData);
    				wp_insert_post($postData);
    			}	
    
    			/// attach the product categories
    			foreach($the_categories as $key => $value ){
    				//// check if exists, get category or if not exists then create the category
    				$theCat = get_term_by( 'slug', sanitize_title_with_dashes(trim(strtolower($value))), 'product_cat');
    
    				if($theCat == NULL) {
    					$term = wp_insert_term (
    							trim(strtolower($value)),
    							'product_cat',
    							array(
    								'description'=>trim($value),
    								'slug'=>sanitize_title_with_dashes(trim($value)),
    								'parent'=>0
    							) );
    					$theCatId = $term['term_id'];
    				} else {
    					$theCatId = $theCat->term_id;
    				}
    
    				if($theCatId){
    					array_push($post_categories, $theCatId);
    				}
    
    			}
    
    			sort($post_categories);
    			$post_categories = array_map('intval', $post_categories);
    
    			var_dump(array( $cID, $post_categories, 'product_cat'));
    			echo '<br /><br />';
    			///wp_set_object_terms( $cID, $post_categories, 'product_cat', true); --- DOESN't WORK
    			//wp_set_post_categories( $cID, $post_categories, false);  --- DOESN't WORK
    			///wp_set_post_terms( $cID, $post_categories); //// --- DOESN't WORK
    			wp_set_object_terms( $cID,  array_map('intval', array(2)), 'product_type');
    			wp_set_object_terms( $cID, $post_categories, 'product_cat');
    			///wp_set_post_terms( $cID, array($post_categories), 'product_cat' );  --- DOESN't WORK
    
    			//// Update the other meta data
    			update_post_meta($cID, '_visibility', 'visible');
    			if($stock > 0) {
    				update_post_meta($cID, '_stock_status', 'instock');
    			} else {
    				update_post_meta($cID, '_stock_status', 'outofstock');
    			}
    			update_post_meta($cID, '_downloadable', 'no');
    			update_post_meta($cID, '_virtual', 'no');
    			update_post_meta($cID, '_regular_price', $price);
    			update_post_meta($cID, '_sale_price', '');
    			update_post_meta($cID, '_purchase_note', '');
    			update_post_meta($cID, '_featured', 'no');
    			update_post_meta($cID, '_weight', '');
    			update_post_meta($cID, '_length', '');
    			update_post_meta($cID, '_width', '');
    			update_post_meta($cID, '_height', '');
    			update_post_meta($cID, '_sku', $sku);
    			update_post_meta($cID, '_product_attributes', 'a:0:{}');
    			update_post_meta($cID, '_sale_price_dates_from', '');
    			update_post_meta($cID, '_sale_price_dates_to', '');
    			update_post_meta($cID, '_price', $price);
    			update_post_meta($cID, '_sold_individually', 'no');
    			update_post_meta($cID, '_pack_qty', $packQty);
    			update_post_meta($cID, '_manage_stock', 'yes');
    			update_post_meta($cID, '_backorders', 'no');
    			update_post_meta($cID, '_stock', $stock);
    			update_post_meta($cID, '_product_image_gallery', '');				
    
    			$count++;
    
    			if($count > 10) {
    				break;
    			}
    
    		} //// End foreach
    
    		/*$xml_post_string .= '</SetProductStockRequest></SetProductStock></soap:Body></soap:Envelope>';   // data from the form, e.g. some ID number 
    
    		$headers = array(
    			"POST: /v1.1/publicapi.asmx HTTP/1.1",
    			"Host: publicapi.ekmpowershop27.com",
    			"Content-Type: text/xml; charset=utf-8",
    			"SOAPAction: https://publicapi.ekmpowershop.com/SetProductStock",
    			"Content-length: ".strlen($xml_post_string)
    		); //SOAPAction: your op URL
    
    		// PHP cURL  for https connection with auth
    		$ch = curl_init();
    		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    		curl_setopt($ch, CURLOPT_URL, $url);
    		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    		///curl_setopt($ch, CURLOPT_USERPWD,"EF_PSSTORE:016e3f2663377b6191151e69ace48686"); // username and password - declared at the top of the doc
    		curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
    		curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    		curl_setopt($ch, CURLOPT_POST, true);
    		curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
    		curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    
    		// converting
    		$response = curl_exec($ch);
    		curl_close($ch);
    
    		// converting
    		$response1 = str_replace("<soap:Body>","",$response);
    		$response2 = str_replace("</soap:Body>","",$response1);
    
    		// converting to XML
    		$item = simplexml_load_string($response2);
    		$parser[] = simplexml_load_string($response2);
    		if($item->SetProductStockResponse->SetProductStockResult->Status == 'Success') {
    			echo '<pre style="color:green" >';
    			var_dump(simplexml_load_string($response2));
    			echo '</pre>';
    		} else {
    			echo '<pre style="color:red" >';
    			var_dump(simplexml_load_string($response2));
    			echo '</pre>';
    		}
    		echo '<hr />';
    
    		*/
    		die();
    		return $parser;
    
    	} /// End function
    Thread Starter Andi Lee Davis

    (@andi-lee-davis)

    Nope that doesn’t work.

    Thread Starter Andi Lee Davis

    (@andi-lee-davis)

    I thinks this solved it…

    if($jobs->post_count != $original_post_count) {
    				///sort($jobs->posts);
    				$jobs->current_post--;
    				$jobs->posts = array_values($jobs->posts);
    				///error_log ("\n\nalert count jobs " . $jobs->post_count . " != " . $original_post_count . " HAVE POSTS: " . $jobs->have_posts() . ' : ' . $jobs->current_post . "\n\r" . print_r($jobs,true) , 3 , '/var/www/vhosts/limetest.eu/httpdocs/harpwallen/testCountJobs.log', NULL );
    
    			}
    Thread Starter Andi Lee Davis

    (@andi-lee-davis)

    Same with these…

    if (isset($_POST['show_arrows']) && $_POST['show_arrows'])
    				$options['show_arrows'] = (bool)true;
    			else
    				$options['show_arrows'] = (bool)false;
    
    			if (isset($_POST['show_paging']) && $_POST['show_paging'])
    				$options['show_paging'] = (bool)true;
    			else
    				$options['show_paging'] = (bool)false;

    If the developer of this plugin contacts me I can send an updated zipped file with all the fixes to this plugin.

Viewing 15 replies - 31 through 45 (of 55 total)