I offer free delivery on orders over £75 in my store, so I'd like to show an additional <div> element on each product page where the product price is 75 or greater.
I had assumed I could use conditional handlebar commands like this:
{{#if price.with_tax.raw >= 75}}
<div>Qualifies for free delivery</div>
{{/if}}
But this just gives me a 500 error.
Is this sort of conditional logic even possible, and if so, what is the correct syntax? Is price.with_tax.raw the right stencil object to use?
Try this:
{{#if price.with_tax.value '>=' 1}}
show something
{{/if}}
Related
I have a multiple option select and everytime i submit the page i get:
ERR-1002 Unable to find item ID for item "clients1" in application
for day in {something}
htp.p('<select class="custom-select" name="clients'||to_char(day+1)||'" id="clients'||to_char(day+1)||'" multiple>
<option selected>Open this select menu</option>');
for client in (SELECT id, name FROM client) loop
htp.p('<option value="'|| client.id ||'">'|| client.name ||'</option>');
end loop;
htp.p('</select></div></div></div>');
Looks like this :
<select class="custom-select" name="clients1" id="clients1" multiple=""><option selected="">Open this select menu</option>
<option value="1">Test</option>
...
</select>
I really can't find the problem. Tried to search for an answer but could not find anything.
Thanks in advance
APEX assumes that a form element such as a select list is an APEX page item if its name and id are the same, which yours are. So you can avoid this problem by making the names different from the IDs in some way.
The usual way to create bespoke form elements on an APEX page is to use the APEX_ITEM package, which has functions like SELECT_LIST_FROM_QUERY to generate form elements whose values can be accessed from PL/SQL after page submit via APEX_APPLICATION arrays.
Collection "notes" (markdown): meteor **amazing** and reactjs *learning next*
Collection "links": google - www.google.com and stackoverflow - www.stackoverflow.com
I want to display the notes and links in ONE LIST sorted by the creation date:
1. google - www.google.com
2. meteor - amazing
3. reactjs - learning next
4. stackoverflow - www.stackoverflow.com
and NOT like that:
1. meteor - amazing
2. reactjs - learning next
1. google - www.google.com
2. stackoverflow - www.stackoverflow.com
The "notes" and "links" collections have a completely different structure:
notes = new Mongo.Collection('notes');
{{#each note}}
{filename}}
{{#markdown}} {{note}} {{/markdown}}
{{/each}}
links = new Mongo.Collection('links');
{{#each link}}
{filename}}
<a href={{link}}> {{link}} </a>
{{/each}}
QUESTION:
Should I have one collection for both of them? Is there a Package for this? Or how can I solve this?
If one Item is changed, only this Item should be rendered again.
.fetch() the documents and keys you want from each collection.
.map() the keys from each array into a set of common keys
You'll now have two arrays with common keys
Append one array to the other
Sort the whole array by the key you want to sort by
Return that array from your helper
Display in a single template
Alternatively you can omit step 2 and keep each document in its original structure but then your template is going to have to recognize what kind of document its rendering and display it accordingly.
Is there a way to do a meteor find (yes, it will be part of a publish function later, i'm just trying to test this)
that is filtered by more than one field at a time?
for example, let's say I only want to return those users who work at Disney in the IT department.
so far I have
Template.managerReports.disney = function () {
return employees.find({'company':"disney"});
};
//for template helper binding to
<template name="managerReports">
{{#each disney}}
<p>{{name}}</p>
{{/each}}
</template>
and attempts to add multiple comma-separated {field:value} pairs results very nicely in these ALSO being found and added to the disney results. I want to reduce results per added field. only data that matches multiple fields gets found.
am I being totally dumb? what is the usual meteor way to deal with multiple conditional finds?
If you want to find users who work for disney AND in the IT department:
employees.find($and: [{company: 'disney'}, {department: 'it'}]);
However, mongodb provides an implicit AND operation when specifying a comma separated list of expressions. So this is more commonly written as:
employees.find({company: 'disney', department: 'it'});
If you want to find users who work for disney OR in the IT department:
employees.find($or: [{company: 'disney'}, {department: 'it'}]);
You need to pass a javascript object, not comma-separated values:
Employees.find({
company: 'disney',
department: 'marketing',
salary: {$gt: 100000},
});
Let's say I have a simple product_orders collection in Meteor (_id, user_id, user_name, product_name, price_unit, quantity) and I want to show all orders of a single user in table where each row should contain:
user_name, product_name, quantity, price_unit, quantity, price_total (price_unit * quantity)
Additionally I would like to display a grand total for all user's orders.
I don't see easy way to do this in Handlebars.js template as Handlebars doesn't appear to support simple math operations. I can easily return product_order's cursor to my template but don't see easy way to calculate price_total and grand total in template.
I am thinking of creating a template helper of some sort but not sure if that's the proper direction to go. This problem looks like it must have a simple & elegant solution.
Yes, you should write a helper. Handlebars doesn't support using logic in the templates (which is a good practice as it forces you to apply the separation of concerns pattern).
A template helper looks like this:
Handlebars.registerHelper("grandTotal", function(user_name) {
var grandTotal = some_magic_to_calc_total(user_name);
return grandTotal;
});
Then you can call the helper like this from your template:
<template name="foo">
{{grandTotal user_name}}
</template>
You can read more about helpers in the Handlebars.js docs.
I am using custom field query plugin for wp in my site. I wanted to create sorting option for custom field 'price' for front end user to sort price from option lowest to highest and highest to lowest. To use the custom field query plugin, I register the function in my headwaytheme.
add_action('init', 'register_From_Price');
function register_From_Price(){
register_custom_queryable_field("From_Price", array("dataType"=>"numeric","order"=>"DESC"));
}
Then, I place the following codes:
<span class="lowest">
Lowest
</span>
<span class="highest">
Highest
</span>
It working for the highest to Lowest, but it is not working for the lowest to highest.
I wonder anyone using this plugin can help to advice, thanks.
I am not sure what plugin you are talking about
but i guess this may work
add_query_arg('order_by','From_Price','order'=>'DESC');