how to create payment method per customer group using dynamic field - magento

i want display selected payment method on checkout page for specific customer group using dymanic field .
this is mycode from system config
<group id="general" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>Configuration</label>
<field id="enable" translate="label" type="select" sortOrder="2" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Enable</label>
<source_model>Magento\Config\Model\Config\Source\Enabledisable</source_model>
</field>
<field id="dynamic_field" translate="label" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Payment Method</label>
<frontend_model>Vdcstore\PaymentMethod\Block\Adminhtml\Form\Field\Groups</frontend_model>
<backend_model>Magento\Config\Model\Config\Backend\Serialized\ArraySerialized</backend_model>
<depends>
<field id="enable">1</field>
</depends>
</field>
</group>

Related

Joomla4 : how to set parameters in an extension?

I have developed a Joomla3 extension and I try to run in in Joomla4.1
In my XML file:
<extension version="3.1" type="plugin" group="content" method="upgrade">
<config>
<fields name="params">
<fieldset name="basic">
<field name="webmasterid" type="text" default="" label="Enter webmasterid"/>
<field name="password" type="password" default="" label="Enter Password"/>
</fieldset>
</fields>
</config>
But I don't see any way from my /administrator/ panel where I can set these 2 params:
webmasterid, password
What is the correct way to have them displayed in /administrator/ panel ?
(the plugin still works correctly, but I have to set these values directly in my plugin code)

odoo inheritance of view element without name or id

In odoo I try to change the recruitement form, but some of the stuctural elements dont have a name or id. When I change those elements it works fine initially, but when I upgrade the database then the rendering of the xml is stricter for some reason and gives an ParseError.
The recruitement form:
<sheet>
<div class="oe_button_box" name="button_box"/>
<div class="oe_title">
<label for="name" class="oe_edit_only"/>
<h1><field name="name" placeholder="e.g. Sales Manager"/></h1>
</div>
<notebook>
<page string="Job Description">
<div attrs="{'invisible': [('state', '!=', 'recruit')]}">
<label for="description"/>
<field name="description" type="html"/>
</div>
</page>
<page name="description_page" string="Description">
<field name="description" type="html"/>
<div class="d-none oe_clear"/>
</page>
<page string="Recruitment">
<group>
<group name="recruitment">
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
<field name="department_id"/>
</group>
<group>
<field name="no_of_recruitment"/>
</group>
</group>
</page>
</notebook>
</sheet>
As you can see; the sheet, notebook, pages and groups mostly dont have a name. The string attribute is also not sufficient to modify with a expression in xpath. So it feels like I'm just stuck with this framework.
What I try:
<xpath expr="//sheet/notebook" position="replace">
<notebook>
<page name="description_page" string="Description">
<field name="description" type="html"/>
<div class="d-none oe_clear"/>
</page>
<page string="Recruitment">
<group>
<group name="recruitment">
<field name="branch_concept" />
<field name="branch" />
<field name="department_id" />
</group>
<group>
<field name="no_of_recruitment"/>
</group>
</group>
</page>
</notebook>
</xpath>
And this works until I do a db upgrade, then I get a parseError.
Does anybody know I can use my own structure?
In the xpath expression you use //<some_node> to 'Selects nodes in the document from the current node that match the selection no matter where they are'. You can also use /<some_node>/<some_other_node> to locate a specific element.
for example /form/sheet/notebook/page[1]

odoo wizard cant inherit the model

I created a model like this
class FoundCheque(models.TransientModel):
_name = "found.cheque"
date_Found = fields.Date(string='Found Date', default=fields.Date.context_today, required=True, translate=True)
and its view
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record model="ir.ui.view" id="wizard_found_cheque">
<field name="name">found.cheque.wizard</field>
<field name="model">found.cheque</field>
<field name="arch" type="xml">
<form string="found Cheque">
<group>
<field name="date_found" style="width:40%%"/>
</group>
<footer>
<button name="found_cheque" string="Post" type="object" class="oe_highlight"/>
or <button string="Cancel" class="oe_link" special="cancel"/>
</footer>
</form>
</field>
</record>
</data>
</odoo>
but when I try to update the module after restarting the service
it just says:
Field `date_found` does not exist
Error context:
View `found.cheque.wizard`
[view_id: 4100, xml_id: n/a, model: found.cheque, parent_id: n/a]
None" while parsing /opt/odoo/odoo11-custom-addons/cheque_management/views/found_cheque.xml:4, near
<record model="ir.ui.view" id="wizard_found_cheque">
<field name="name">found.cheque.wizard</field>
<field name="model">found.cheque</field>
<field name="arch" type="xml">
<form string="found Cheque">
<group>
<field name="date_found" style="width:40%%"/>
</group>
<footer>
<button name="found_cheque" string="Post" type="object" class="oe_highlight" confirm="آیا مطمئن هستید؟"/>
or <button string="Cancel" class="oe_link" special="cancel"/>
</footer>
</form>
</field>
</record>
and just to add I restarted the service several times
more information will be added on request
Your field name in python file is date_Found and date_found in xml. Both are different. so change field name in xml file
the defined field in model was "date_Found" and the defined field in wizard was "date_found"
F

Validating a form on a button click in struts 1.2

I am trying to validate user credentials details during application log in.I have changed my struts config and validation xml but the validation gets invoked on the page load itself.
I want that this validation should be invoked only during the click of a button(submit button).
My struts config is as under:
<action-mappings>
<action attribute="loginForm" input="jsp/LoginPage.jsp" name="loginForm"
parameter="method" path="/loginAction" scope="request"
type="com.pcs.bpems.portal.struts.action.LoginAction" validate="false">
<forward name="schoolloginpage" path="/jsp/SchoolLoginPage.jsp" />
</action>
<action attribute="loginForm" input="/jsp/SchoolLoginPage.jsp" name="loginForm"
parameter="method" path="/loginAction" scope="request"
type="com.pcs.bpems.portal.struts.action.LoginAction" validate="true">
<forward name="schoolloginpage" path="/jsp/SchoolLoginPage.jsp" />
<forward name="schoolhomepage" path="/ownerHome.do?method=showHome" />
</action>
My validation xml is as under
<form name="loginForm">
<field property="userId" depends="required,minlength">
<arg0 key="label.userName"/>
<var>
<var-name>minlength</var-name>
<var-value>6</var-value>
</var>
<arg1 key="${var:minlength}" resource="false" />
</field>
<field property="password" depends="required,minlength">
<arg0 key="label.password"/>
<var>
<var-name>minlength</var-name>
<var-value>6</var-value>
</var>
<arg1 key="${var:minlength}" resource="false" />
</field>
</form>
#Anish Try this code instead of your first LoginAction attribute,
<action path="/loginAction" parameter="method"
type="com.pcs.bpems.portal.struts.action.LoginAction" validate="false">
<forward name="schoolloginpage" path="/jsp/SchoolLoginPage.jsp" />
</action>
My thought is form name is not necessary for load the form, though you are made validate attribute to false. Let me know if this helps.
If you do not pass through the input, Struts performs the validation. There are several ways to solve it.
Request directly to the JSP
Make a request to the JSP file directly and not through the org.apache.struts.action.ActionServlet.
http://localhost:8080/MyContext/jsp/SchoolLoginPage.jsp
With a forward
<action path="/login" forward="/jsp/SchoolLoginPage.jsp" />
Use:
http://localhost:8080/MyContext/login.do

Adding additional store addresses

Magento allows you to set five email addresses in the store admin:
General Contact
Sales Representative
Customer Support
Custom Email 1
Custom Email 2
What do I do if I want more?
You need to create a new module (or extends existing one in local code pool) and add a system.xml file.
Here's a quick example. Lets assume that you'd like to add 'Technical support' and 'HR department' email addresses. Your system.xml file would look like this:
<config>
<sections>
<trans_email>
<groups>
<ident_technical translate="label">
<label>Technical Support</label>
<frontend_type>text</frontend_type>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<email translate="label">
<label>Sender Email</label>
<frontend_type>text</frontend_type>
<backend_model>adminhtml/system_config_backend_email_address</backend_model>
<validate>validate-email</validate>
<sort_order>2</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</email>
<name translate="label">
<label>Sender Name</label>
<frontend_type>text</frontend_type>
<backend_model>adminhtml/system_config_backend_email_sender</backend_model>
<validate>validate-emailSender</validate>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</name>
</fields>
</ident_technical>
<ident_hr translate="label">
<label>HR department</label>
<frontend_type>text</frontend_type>
<sort_order>20</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<email translate="label">
<label>Sender Email</label>
<frontend_type>text</frontend_type>
<backend_model>adminhtml/system_config_backend_email_address</backend_model>
<validate>validate-email</validate>
<sort_order>2</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</email>
<name translate="label">
<label>Sender Name</label>
<frontend_type>text</frontend_type>
<backend_model>adminhtml/system_config_backend_email_sender</backend_model>
<validate>validate-emailSender</validate>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</name>
</fields>
</ident_hr>
</groups>
</trans_email>
</sections>
</config>
In your code you can get e.g. Technical support data by
Mage::getStoreConfig('trans_email/ident_technical/email');
I found a blog on this. Maybe this is useful
http://www.excellencemagentoblog.com/magento-sending-custom-emails
You can create a new module and create an adminhtml folder in the etc folder. Here, create a system.xml and add the following code:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<section id="trans_email" translate="label" type="text" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="1">
<tab>general</tab>
<group id="ident_custom3" translate="label" type="text" sortOrder="6" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Custom Email 3</label>
<field id="email" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Sender Email</label>
<validate>validate-email</validate>
<backend_model>Magento\Config\Model\Config\Backend\Email\Address</backend_model>
</field>
<field id="name" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Sender Name</label>
<backend_model>Magento\Config\Model\Config\Backend\Email\Sender</backend_model>
<validate>validate-emailSender</validate>
</field>
</group>
</section>
</system>
</config>
This will add a Custom Email 3 section at Stores ->Configurations ->General ->Store Email Addresses.

Resources