what happening for this line $this->config->get('config_customer_price') - opencart

I didn't get the idea what really happening here $this->config->get('config_customer_price')
if (($this->config->get('config_customer_price') && $this->customer->isLogged()) ||
!$this->config->get('config_customer_price')) {
$price = $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')));
} else {
$price = false;
}

There's an option in the System / Settings page, under the Option tab, and Account section, which is:
Login Display Prices: Only show prices when a customer is logged in.
So, that part of the code is just checking the following:
If this option is set and the customer is logged in, OR if this option is disabled, then: display the price. Otherwise: don't display the price.

Related

Ionic 2/3 :Dynamically set RootPage

I have a scenario where I have 2 profiles (user and admin) and I have a selection page once a person logs in. On the selection page, there are 2 radio buttons for (User and Admin profiles), what I am trying to achieve is, the person can choose only 1 profile (this is achieved by the radio button), now assuming I have saved the selected value, I want to set the rootPage to AdminPage or UserPage, but I don't want to immediately navigate, I just want to update/set the path so that when the person goes back (by pressing the back key or previous button) it will take the person to the desired page. Please let me know your thoughts.
Maby this will put you in the right direction:
https://ionicframework.com/docs/api/navigation/NavController/#insert
do not set adminPage or userPage as rootPage but insert the page on the stack
The trick here is that you want to set the root to a new page after the user tries to go back, the easiest way to achieve this is using the NavController navguards to execute a code before leaving the page, this way it'll check wich page the user has selected and then set the root.
Since the select can be easy impemented following the docs i'll leave that aside. Let's just say you have a property userType that is a string and can be 'user' or 'admin', in your select page you'll do the following:
public canLeave: boolean = false; //this'll controll if the user can leave the page or not
public userType: string = 'user'; // just setting a default value to your select
// this is a navguard
ionViewCanLeave() {
if(!this.canLeave){
if(this.userType == 'user'){
this.canLeave = true; // you'll need to set canLeave to true so when setting the rootpage it doesn't enters the if statemente again
this.navCtrl.setRoot('UserPage');
} else {
this.canLeave = true;
this.navCtrl.setRoot('AdminPage');
}
}
return true;
}
Hope this helps.
I got the solution to the error,
ionViewCanLeave() {
if(!this.canLeave){
if(this.userType == 'user'){
this.canLeave = true; // you'll need to set canLeave to true so when setting the rootpage it doesn't enters the if statemente again
this.navCtrl.setRoot('UserPage'); // <-- this should be UserPage instead of 'UserPage'
} else {
this.canLeave = true;
this.navCtrl.setRoot('AdminPage'); // <-- this should be AdminPage instead of 'AdminPage'
}
}
return true;
}

Apex5, tick all and untick all checkbox

I want a checkbox in an Interactive Report (IR), and I want the users to be able to quickly Select All or Unselect All of them with a single checkbox in the header.
Added java scripted code but it's not working any idea .....
if ( $( '#selectunselectall' ).is(':checked') ) {
$('input[type=checkbox][name=f01]').attr('checked',true);
Else
$('input[type=checkbox][name=f01]').attr('checked',false);
Add the checkbox to the query, e.g. apex_item.checkbox(1, record_id) as selected.
Set the region Static ID to some value, e.g. myreport
Set the following attributes of column “SELECTED”:
Heading = <input type="checkbox" id="selectunselectall">
Escape Special Characters = No
Enable Users To = (uncheck all options, including Hide, Sort, etc.)
Add a Dynamic Action:
Event = Change
Selection Type = jQuery Selector
jQuery Selector = #selectunselectall
Event Scope = Dynamic
Static Container (jQuery Selector) = #myreport
True Action = Execute JavaScript Code
Fire On Page Load = No
Code =
if ($( '#myreport #selectunselectall' ).is(':checked')) {
$('#myreport input[type=checkbox][name=f01]').attr('checked',true);
} else {
$('#myreport input[type=checkbox][name=f01]').attr('checked',false);
}
Amendment made to jeff's code:
if ($( '#myreport #selectunselectall' ).is(':checked')) {
$('#myreport input[type=checkbox][name=f01]').prop('checked',true);
} else {
$('#myreport input[type=checkbox][name=f01]').prop('checked',false);
}
jQuery API - .prop()
Jeff Kemp's select/unselect all
Have a look at the above link. Jeff Kemp has done a great job documenting your objective.

ADOTable cancel updates in row before post

I have a remote database mysql, connected to the application (C++ Builder 6) using ADOConnection, and DBGrid, which is displayed data (ADOConnection-ADOTable-Dataset-DBGrid).
ADOTable by default can not be edited; by clicking on the button "Edit", I write "readonly = false", and edit data.
After editing the line (for example, the cursor moved to the line above), I need to prompt the user ("Save changes? Y / N"), and when you select "No", to undo the changes.
On request there is no problem. The question is how I should undo the changes (preferably still on the client, ie ADOTable or DBGrid)?
Okay, got it myself. Three weeks of headache, and five rows of code.
if (DataSet->State == dsEdit || DataSet->State == dsInsert){
int res = MessageBox(Handle, "Save changes?", "Confirm", MB_YESNO);
if (res == IDNO){
DataSet->Cancel();
Abort();
}
}
Also, if we click on other field, and select "No", cursor would not move. But that's not a problem for now.

How to abort saveui pipeline in Sitecore and then reset values?

I am trying to implement a saveui pipeline processor in Sitecore 6. Basically I have created a custom processor that presents the user with a popup message depending on which fields they may have changed on the item and what the new data is. If they made certain changes then they are presented with a popup asking them if they want to continue. If they answer no then the pipeline is aborted. That is all working. However I noticed that when you abort the pipeline all Sitecore seems to do is not save. All of the changes that the user made to the content item are still there in the UI. If you navigate away from the item in Sitecore, it will prompt you if you want to save the changes. Is there some way that I can get the Sitecore UI to cancel all of the changes and revert all of the fields back to their initial values? Aborting the pipeline is good because I don't want to save, but I also want to cancel the save in the UI too. Does anyone know how to do this?
Sample Code:
public class CustomSaveProcessor
{
public void Process(SaveArgs args)
{
Sitecore.Diagnostics.Assert.ArgumentNotNull(args, "args");
if(args.Items == null)
{ return; }
if(args.IsPostback)
{
if(args.Parameters["runContext"] == "firstQuestion")
{
if((args.Result == null) || (args.Result == "null") || (args.Result == "no") || (args.Result == "cancel"))
{
args.AbortPipeline();
//Should there be something here to tell the Sitecore UI to reset the values?
return;
}
else
{
//User has answered first question Yes
//This means they want to save the changes to the item
//We also want to ask a second question that effects other content items
SheerResponse.YesNoCancel("Do you want to also modify other items?", "300px", "200px");
args.Parameters["runContext"] = "secondQuestion";
args.WaitForPostBack();
}
}
else
{
if(args.Result == "yes")
{
//This is the answer to second question
//Custom code here to modify other content items
}
//We are completely done now.
return;
}
}
else
{
//Ask the user the first question
SheerResponse.YesNoCancel("Are you sure you want to proceed?", "300px", "200px");
args.Parameters["runContext"] = "firstQuestion";
args.WaitForPostback();
}
}
}
You can just reload the content tree with the following code.
String refresh = String.Format("item:refreshchildren(id={0})", Sitecore.Context.Item.Parent.ID);
Sitecore.Context.ClientPage.SendMessage(this, refresh);
Or as Corey discovered if you want to refersh the item you'd use
String refresh = String.Format("item:load(id={0})", myOriginalItem.ID);
Sitecore.Context.ClientPage.SendMessage(this, refresh);
See this post for more details
I think you can try to reload the current content item after aborting your custom save handler to set the intial values of the content item. Not sure if you then still get the "alert message".
Take a look at this post with a similiar issue

Django's filter_horizontal - stop enter presses submitting the form

I'm not sure if I'm doing something wrong, if there's something broken about filter_horizontal, or if my expectations of the way it should behave are wrong. Any insights appreciated!
In my mind, when you use filter_horizontal, type a few characters into the text box to narrow down your choice such that there's a single item, and hit enter, it should:
Add the item to the selected list
clear your entered text (allowing you to add another).
What it actually does is:
Add your item to the selected list
Keep the text in the filter box
Submit the form, without saving your new selection
Am I doing something wrong? Is this the behaviour everyone sees? Is there a way to work around this?
I'm using Django 1.2.3, and I've tested this in Chrome 8.0.552.237, Firefox 3.6.13, and IE 8.
I can confirm the behavior on Django 1.2.1.
Problem:
It looks like admin/js/SelectFilter2.js registers a key up handler to do the filtering. This handler also returns false if the key was the enter key, which tries to cancel the form submit.
From admin/js/SelectFilter2.js line 85 or so:
// don't submit form if user pressed Enter
if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) {
from.selectedIndex = 0;
SelectBox.move(field_id + '_from', field_id + '_to');
from.selectedIndex = 0;
return false;
}
This seemed fine to me, so I added an event handler at the end of the init method to catch the form's submit event:
addEvent(document.forms[0], 'submit', function(event) {
console.log("Form submitted");
}
After doing that, it's clear that submit fires before the keyUp event. Thus, pressing enter submits the form, and the keyUp event never gets to the field.
Workaround:
I was able to work around the behavior by discarding all enter keyUp's on the form itself. Add this to the end of the init method in SelectFilter2.js:
addEvent(document.forms[0], 'keyup', function(event) {
if (event.keyCode && event.keyCode == 13) {
return false;
}
});
This is the quick and dirty way to fix the problem, but the form event fires after the field's event, so it seems to work. But it also stops the enter key from submitting the form everywhere else too.
This should probably be filed as a django bug.