Hide Confirm button on checkout page from plugin nopcommerce - nopcommerce

Introduction
I am working on a plugin which will need a "Confirm" button hide on some condition (written in action filter).
Question:
How to hide Confirm button on checkout page from plugin in nopcommerce.
Problem
Actually i cannot make view overrides (and using ViewData) as suggested in some solutions but i cant do override in views.
Thinking about having solved from action filter i wrote for /Checkout/Complete --get
//if checkout process is generic
bool IsCheckoutConfirm = (filterContext.RouteData.Values["controller"].Equals("Checkout")
&& (filterContext.RouteData.Values["action"].Equals("Confirm")) && filterContext.HttpContext.Request.HttpMethod == "GET");
If someone have idea or know how it can be done, please help me out.
Thanks for your time.

The easiest way to do this is to make a copy of the Confirm.cshtml page and put it one of these two places:
The views/checkout/ folder of your theme
Create a folder structure in your plugin for Themes/views/checkout/
Once you have your copy of the Confirm.cshtml you can wrap the confirm button inside an "if" condition, coded for the Boolean value in your plugin that determines whether to expose the button.
There are a variety of ways to pass that value, either by extending the CheckoutConfirmModel in your plugin, action filters, etc.

Related

Disable Drupal redirecting to page view after edit

How do I disable the edit page redirecting to either the page view or the list of site contents upon saving?
I prefer to keep the edit page open whilst refreshing the page view in another browser window, and it is really annoying having to click back into the edit view every time I click on 'Save'.
I cannot find anything in the documentation or online telling me where I can turn off this behaviour ?
If you want this behaviour both on node creation and update, and for every content-type, you can do something like:
function hook_node_insert($node) { // and for hook_node_update
$_GET['destination'] = 'node/' . $node->nid . '/edit';
}
EDIT : Of course I don't know your Drupal level so I didn't say that you have to put it in a custom module, etc, etc. If you need more information about that, just ask ;-)
Use this module, it adds an extra button to save and stay in edit: https://www.drupal.org/project/save_edit

Drupal Views Module is stuck on my custom theme

So I was going through the settings in the Views Module and hit a checkbox and clicked save. This unfortunately transformed the entire Views UI into my custom theme's homepage. And trying to go into settings does not allow me to see anything except my custom homepage. I've tried uninstalling the module and deleting EVERYTHING but nothing seems to work. How can I manually undo check whatever box I had checked.
it needs a little bit of debugging.
go into views source code, look for .module files and search for
hook_menu() implementation
find there an URL where you have checked that checkbox
go into page callback function
check for submit callback function and go to that function
look for update queries or variables settings, anything that have a machine name of your checkbox, look for the mysql table and field
go into database and update that field to your needs
you can also use a fresh drupal install to perform this, it will be easier to just copy the value from one database field into another

How to modify the Node Edit or Insert Form in Drupal

I am having trouble finding sources of information or example code for a creating a custom module (or any means) to edit the node edit/insert pages.
I am trying to create a Flickr Integration for a node. The Flickr API is not an issue and i can resolve those, it's the Drupal API issues i could use some help or resources of information on.
Here is what i am trying to achive.
User attempts to add or edit a node
User inserts a keyword into a field and presses a button (Get Photos)
Flickr API returns and displays a few images
User clicks on an image and the URL of the image is then added to an input field
on node save or node update a field such as $node->flickrImage[0][value] is updated with the URL selected in 4.
the variable is the available when ever the node is rendered.
I'm not quite sure how to achieve this - I simply need some example code of modifying the node edit/insert pages and I think I can work the rest out.
Please Help!
Thanks,
Shadi
It looks for me, that you can write own CCK field type, so that you can add this to desired content type and process user's input & work with flickr API.
this way, it's easier to manage this field and control it, plus it will be automatically added to node edit/create forms, node loads, etc.
This article might help http://www.lullabot.com/articles/creating-custom-cck-fields
Second way, is to use hook_form_alter
function module_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'product_node_form') {
//do smth
}
}
In this case, form_id you want to change, will be {content_type}_node_form.
there you can add your field, and process it on
hook_nodeapi
Here is a link for node edit form alter solution ..
http://drupal.org/node/101092

Drupal views & to do list

Wondered if anyone can tell me whether the following is possible within views.
I have installed To do module - http://drupal.org/project/to_do
I then created my own view which lists all the tasks created in a particular Organic Group, which works lovely.
One of the fields ive added as the to do button field which gives the user the ability to mark a task as finshed from the view listing.
the problem I have is that all users part of that group can see that buton & has the ability to mark the task as finished.
Is there a way I can use views to only show that button if the current logged in user is the author of that node( to do task).
Views have different templates. In one of them all the fields are being printed. You could in that template make a check if the user is the author and then only print the todo field.
You cam click the theme information link inside the view to get a list of templates that's used and what you could call a custom template for views to use it.
This will only show content the user created. It's a pretty simple argument

Drupal CCK Field Level Visibility

I am using the Drupal 6 module Content Profile to allow using a CCK defined type as a user profile which is working well. The issue I have is that I want the first completion of the profile to trigger an action however the user may save the profile without completing it. My thoughts on this is to have a checkbox by the save button which states 'My profile is complete' which the user will select once they are happy with it, and I have another module which creates a trigger by using the node_api hook and checking the type of the node, the action, and the value of this checkbox.
Once this trigger has been raised I don't want that checkbox to appear again however. If I could set the visibility of the checkbox using PHP code that would work as I could write a short script to determine if the completed action has already happenede and if so hide the checkbox. Is there a module that allows this? I haven't been able to find one.
I have also looked at using the same node_api hook to manipulate the profile as it is being displayed however the node just seems to have the values for the fields and not a form object that can be manipulated as I would have expected. IS there a way to programatically manipulate a CCK form?
Thanks
I think hook form alter is what you are after. This can perform alterations to a form before it is rendered.
I would suggest another approach using the Save & Edit module. Set your CCK profile type as "unpublished" by default. Allow users to save it and/or save AND publish it with this module. On publish, use triggers and actions.
This approach is arguably more in keeping with the Drupal way - configuration over customization.

Resources