Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

Menu order option in quick edit?

$
0
0

Replies: 0

I want to show the menu order field in a quick edit. I created a custom field that is showing correctly in the quick edit box, but the issue is how can I save the quick edit menu option to woocommerce product menu option? I tried some code without success.

JQuery Code:

jQuery(document).ready(function(){

	jQuery(".acf-quick-edit input[type='text']").blur(function(){
		var morder = jQuery(this).val();
		var post_id = jQuery(this).parents("tr").attr("id");

		var data = {
			'action': 'update_menu_order',
			'menu_order': morder,
			'post_id':post_id
		};

		// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
		jQuery.post(ajaxurl, data, function(response) {
			alert(response);
		});

	});

	});

PHP Code:

<?php 

	add_action( 'wp_ajax_update_menu_order', 'update_menu_order' );
	add_action( 'wp_ajax_nopriv_update_menu_order', 'update_menu_order' );

	function update_menu_order() {
		global $wpdb; // this is how you get access to the database

		$menu_order = $_POST['menu_order'];
		$data = $_POST['post_id'];
		$post_id = substr($data, strpos($data, "-") + 1);    
	//print_r($_POST);
	//echo get_post_field( 'menu_order', $post_id);
	update_post_meta($post_id,'_menu_order',$menu_order);

		

		wp_die(); // this is required to terminate immediately and return a proper response
	}

Viewing all articles
Browse latest Browse all 59525

Trending Articles