Forum Replies Created

Viewing 15 replies - 121 through 135 (of 152 total)
  • Thread Starter crdunst

    (@crdunst)

    Hi Kevin,

    Further to my original query, and thanks to the link you posted, I have been able to create a custom field and populate it with woocommerce products.

    My new field shows in admin, and displays the products correctly, and I’m able to add it to my form, but I can’t get it to display on the front-end.

    The example on the link you posted is for a text field only, so I tried to copy from the examples within the plugin /includes/fields/ directory, but I’m not able to get it to work – it just displays an empty dropdown. If I just print out the data, it only shows the first product in my list. Do you have any ideas how I can display the list on the front-end? I thought you might have a quick pointer to help?

    Kind thanks

    // create a new field type for woocommerce products
    // get a list of woo products
    $woo_args = array (
    	'post_type' => 'product',
    	'posts_per_page'  => 5
    );
    $woo_products = get_posts($woo_args);
    $woo_products_select = array();
    foreach($woo_products as $woo_product) {
    	$woo_products_select_item = array(
    		'name' => $woo_product->post_title,
    		'value' => 'product-'. $woo_product->ID .'-'. $woo_product->post_name
    	);
    	array_push($woo_products_select, $woo_products_select_item);
    }
    
    // create the custom ninja field using the woo products
    $args = array(
        'name' => 'Product List',
        'edit_options' => array(
            array(
                'type' => 'select',
                'name' => 'select_woo_products',
                'label' => 'WooCommerce Products',
                'options' => $woo_products_select,
            ),
        ),
        'display_function' => 'select_woo_products_display',
        'sidebar' => 'template_fields'
    );
    
    if( function_exists( 'ninja_forms_register_field' ) ) {
        ninja_forms_register_field('select_woo_products', $args);
    }
    
    /*
     *	This function only has to output the specific field element. The wrap is output automatically.
     *
     *	$field_id is the id of the field currently being displayed.
     *	$data is an array the possibly modified field data for the current field.
     *
    */
    
    function select_woo_products_display( $field_id, $data ){
    	// should output the list within here
    	print_r($data);
    	// just outputs the first item in the list - how do I get all of the items?
    }
    Thread Starter crdunst

    (@crdunst)

    Yes the filter just saved having to mess around with jquery and is already done – the filter is a much more robust way of pre-populating.

    If it helps anyone else, add this to your functions file to pre-populate your values. The example below pre-populates a dropdown and three text fields. Just remove/duplicate as needed and change the references to the form items:

    // filter runs every time a form element is rendered
    add_filter('ninja_forms_field','apply_prepop');
    function apply_prepop($data) {
    
    	// check which form element is being displayed, and if we have a value being posted, select/replace it
    	if($data['label']=='Title' && $_POST['apply-title']) {
    		foreach ($data['list']['options'] as $key => $value) {
    			if($value['label'] == $_POST['apply-title']) {
    				$data['list']['options'][$key]['selected'] = 1;
    			}
    		}
    	}
    
    	if($data['label']=='First name' && $_POST['apply-name']) {
    		$data['default_value'] = $_POST['apply-name'];
    	}
    
    	if($data['label']=='Last name' && $_POST['apply-surname']) {
    		$data['default_value'] = $_POST['apply-surname'];
    	}
    
    	if($data['label']=='Email Address' && $_POST['apply-email']) {
    		$data['default_value'] = $_POST['apply-email'];
    	}
    
    	return $data;
    }
    Thread Starter crdunst

    (@crdunst)

    That’s great, and thanks for the quick and comprehensive reply. This will also help me with something else I’m working on as we speak – to pre-populate a form based on data posted to a page.

    Thanks again!

    Thread Starter crdunst

    (@crdunst)

    No problem, thanks for getting back to me

    OK, this was driving me mad too, but I figured out the problem.

    Go into your edit product page, click on ‘attributes’ in the product data box.

    Click each attribute (colour/size/whatever) and ensure the ‘Visible on the product page’ and ‘Used for variations’ are checked. Click save attributes, save your product.

    It worked for me at least, worth checking yours are enabled.

    Hey there, I’m a bit late to help you I suspect, but for anyone else finding this thread – ensure your product has a price. If it has no price it won’t show the add to cart options.

    Thread Starter crdunst

    (@crdunst)

    Hi Coen,

    Just some high level ideas for improvement with the docs:

    1) Biggest impact: pull the docs together in one place. I understand the idea of premium support when you’re logged into WooThemes, but perhaps this should just be Q/As or forum threads with Woo reps. At the minute, there is static help content in a few places:
    https://wcdocs.woothemes.com/
    https://docs.woothemes.com/
    https://www.woothemes.com/support-faq/
    https://support.woothemes.com (the knowledge base here)

    This is just static content without taking into account the multiple support forums on your sites and WP sites.

    2) Improve the UI for the docs. For example, go to https://wcdocs.woothemes.com/. Click on say ‘Account Funds’ in the main content area. You’re taken to a page on a different domain, and you lose the main nav. The breadcrumb links take you to a different homepage(docs.woothemes.com) with a completely different UI.

    3) Tighten up on things that don’t work. Again, on the https://wcdocs.woothemes.com, try a few items in the left nav = 404s. Also go to https://www.woothemes.com/product-category/themes/ – I find that the filters don’t work properly when combined. Try filtering to show woocommerce and free, or responsive and free, it doesn’t work with a combo of filters.

    4) Tighten up on docs that could be improved. I can’t remember specific examples, but over the last 10 months I’ve been using WooCommerce, I anecdotally remember reading doc pages that either just explained the obvious i.e. explaining an admin page with explanations you could guess from the label, rather than in a little more depth that explains what the effect of that option is. (Sorry for throwing this out there without a specific example).

    One good one I found this very morning where a bit of improvement would have saved me a lot of time – I was setting up a site with Wootique theme. I needed some dummy products, so thought to do a search to see if there was anything out there to populate my site. Lo and behold you guys have this page – https://www.woothemes.com/theme-demo-content/ – a brilliant example of the great tools you provide, and much appreciated. I imported just the xml, but my products weren’t showing on my site. I tried for a while changing a few things, changing my categories, looking at my page templates, it wouldn’t work, just a ‘no products’ message. I eventually found the answer buried in a comment thread on a third-party site. I had to go into each dummy product and re-save to get it to show. Simple, when you know how. If this was on the page where I downloaded the data from it would take it from good to great.

    Hope the above helps and you take it as constructive rather than critical. Like I mentioned in my original post I’m a huge fan, and hugely grateful for the tools you provide, and I’d still give you 5-stars even with the above gripes about the docs.

    Thanks

    crdunst

    (@crdunst)

    Take a look at this – you need to declare support for WooCommerce, maybe this would solve your problem:

    https://docs.woothemes.com/document/declare-woocommerce-support-in-third-party-theme/

    crdunst

    (@crdunst)

    I can’t remember off the top of my head, but I think there’s an option for ‘payment on collection’? You could maybe make use of that?

    crdunst

    (@crdunst)

    Hi zzzlumber,

    Updates to WP are a good thing – many times they fix security holes, small bugs, or make little improvements to the UI. I’d be more worried about using a framework that isn’t kept up-to-date.

    I’ve used (and built with) many Content Management Systems, and in my mind, no other CMS comes close. WP is incredibly flexible to build with, and there’s a huge community of people in the support forums and building themes/plugins.

    Not all upgrades require fixing. The latest WP upgrade to 3.5 made significant changes to the handling of the media gallery, and this plugin makes significant use of that media gallery, hence the comments and upgrade. In my experience, most plugins I use regularly worked with 3.5 without any problems.

    Stick with it – you can always wait to upgrade in the future – you don’t have to upgrade your site straightaway – wait until you’re sure all of the plugins you use are compatible.

    Hi there,

    I just found a small bug. Everything is working fine for me generally, but I added a caption to a widget, then changed my mind and tried to remove the caption, but I couldn’t clear it out – it comes back when you save.

    I had to kill the widget instance and create another, then add an image without a caption.

    Thanks

    That’s right, it’s only visible under Appearance > Widgets, then you can drag it to your widget area on the right-hand side, presuming your theme supports widgets?

    Once I drag the Enhanced Text Area widget into the widget area, and click to expand it, I get all of the fields I should have such as title, content, class etc etc. Saving works fine, and it displays correctly in my theme.

    Hi, just thought I’d let you know it works for me in 3.5.1 with a custom theme – could it be an issue with your theme?

    Thread Starter crdunst

    (@crdunst)

    Hi theresavs, thanks for the info. I always found RSS easy to work with too, but twitter are dropping support for RSS in favour of json.

    A little snippet such as the following would get the latest twitter post using their json format:

    <?php
    $twinfo = json_decode(file_get_contents('https://api.twitter.com/1/users/lookup.json?screen_name=accountnamehere'));
    ?>
    <p><?php echo $twinfo[0]->status->text; ?></p>

Viewing 15 replies - 121 through 135 (of 152 total)