我已经为启用/禁用模块创建了配置。如果我从配置设置中选择“是”,则我的模块在前面可见,否则不可见。为此,我在 checkout_cart_index.xml 中添加了 ifConfig 条件。xml代码如下。
<referenceContainer name="cart.summary">
<block class="Mageniks\Test\Block\Test" before="-" ifconfig="mageniks/general/active" name="displaytest" template="Mageniks_Test::cart.phtml">
</block>
</referenceContainer>
<referenceBlock name="checkout.cart.totals">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="block-totals" xsi:type="array">
<item name="children" xsi:type="array">
<item name="fee" xsi:type="array" remove="true">
<item name="component" xsi:type="string">Mageniks_Test/js/view/checkout/cart/totals/fee</item>
<item name="sortOrder" xsi:type="string">20</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">Mageniks_Test/checkout/cart/totals/fee</item>
<item name="title" xsi:type="string" translate="true">Fee</item>
</item>
</item>
</item>
</item>
</item>
</argument>
</arguments>
</referenceBlock>
Run Code Online (Sandbox Code Playgroud)
Ifconfig 仅在使用块时才起作用。Ifconfig 在参数中不起作用。
我想在参数或项目标签中添加条件以启用和禁用模块(如块标签)。
我怎样才能做到这一点 ?请帮我。任何帮助,将不胜感激。
谢谢
我成功地在Magento 2中制作了helloworld简单模块.现在我想从数据库中获取模型数据...所以请帮助我在Magento 2中获取模型.任何帮助将不胜感激.
我在Magento 2中开发了"Hello world"扩展.
我想覆盖联系我们的核心文件形式.什么是覆盖的正确方法联系我们Magento 2中的表单文件.
请帮我.任何帮助,将不胜感激.
我创建了一个模块,以便为订单增加额外费用.在我下订单时,在前面成功添加额外费用.但在管理员方面没有增加任何额外费用.请帮助我在哪里错误地向管理发票中添加额外费用?.我在Model中创建了collect方法.代码如下.
namespace Mageniks\Alltest\Model\Total;
class Fee extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal
{
protected $quoteValidator = null;
protected $_checkoutSession;
public function __construct(\Magento\Quote\Model\QuoteValidator $quoteValidator, \Magento\Checkout\Model\Session $checkoutSession)
{
$this->quoteValidator = $quoteValidator;
$this->_checkoutSession = $checkoutSession;
}
public function collect(
\Magento\Quote\Model\Quote $quote,
\Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment,
\Magento\Quote\Model\Quote\Address\Total $total
) {
parent::collect($quote, $shippingAssignment, $total);
$exist_amount = 0; //$quote->getFee();
$giftprice = $this->_checkoutSession->getGiftwrapprice();
$fee = $giftprice;
$balance = $fee - $exist_amount;
$total->setTotalAmount('fee', $balance);
$total->setBaseTotalAmount('fee', $balance);
$total->setFee($balance);
$total->setBaseFee($balance);
$total->setGrandTotal($total->getGrandTotal() + $balance);
$total->setBaseGrandTotal($total->getBaseGrandTotal() + $balance);
return $this;
}
protected function clearValues(Address\Total $total)
{
$total->setTotalAmount('subtotal', 0);
$total->setBaseTotalAmount('subtotal', …Run Code Online (Sandbox Code Playgroud) 我创建了一个测试脚本文件,用于使用自定义选项将产品添加到购物车中。我想以编程方式显示购物车中产品的选定自定义选项。
请检查我下面的代码:
$productId = 25;
$product = $objectManager->create('\Magento\Catalog\Model\Product')->load($productId);
$cart = $objectManager->create('Magento\Checkout\Model\Cart');
$params = array();
$params['options[469]'] = 459;
$params['qty'] = 1;
$params['product'] = 25
$cart->addProduct($product, $params);
$cart->save();
Run Code Online (Sandbox Code Playgroud)
我使用objectmanager创建了购物车和产品对象。当我在浏览器中触发此脚本时,显示错误信息:
Magento \ Framework \ Exception \ LocalizedException:请指定产品的必需选项。
我已经在params数组中通过了自定义选项。但仍然显示错误。
如何使用选定的自定义选项将产品添加到购物车?
请帮我。
任何帮助,将不胜感激。
我正在使用spring security 3.0.在spring-security.xml中,显示登录页面时出现1个问题.Web浏览器中没有加载或丢失CSS的login.jsp.所以请解决这个问题..任何帮助,我感谢你.
我的spring-security.xml代码如下:
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.3.xsd">
<http auto-config="true" use-expressions="true">
<intercept-url pattern="/login.html" access="permitAll" />
<intercept-url pattern="/logout" access="permitAll" />
<intercept-url pattern="/accessdenied" access="permitAll" />
<intercept-url pattern="/**" access="hasRole('ROLE_USER')" />
<form-login login-page="/login.html" default-target-url="/firstwelcome.html" />
<logout logout-success-url="/logout" />
</http>
<authentication-manager alias="authenticationManager">
<authentication-provider>
<password-encoder hash="md5"/>
<jdbc-user-service data-source-ref="dataSource"
users-by-username-query="
SELECT strUSERNAME, strPASSWORD, CASE blENABLED WHEN 1 THEN 'true' ELSE 'false' END 'ENABLED'
FROM TBLUSERS
WHERE strUSERNAME=?;"
authorities-by-username-query="
SELECT strUSERNAME, strROLENAME
FROM TBLUSERS
WHERE strUSERNAME=?;"
/>
</authentication-provider>
</authentication-manager>
</beans:beans>
Run Code Online (Sandbox Code Playgroud)
我的login.jsp的标题如下
<link rel="stylesheet" type="text/css" …Run Code Online (Sandbox Code Playgroud) 我正在使用Magento 2.1.3.我想在成功页面之前在访客结账时获取订单ID.我在谷歌搜索,发现了一些这样的代码.
$orderIncrementId = $this->checkoutSession->getLastRealOrderId();
Run Code Online (Sandbox Code Playgroud)
使用chcekout seesion\Magento\Checkout\Model\Session对象,我尝试获取订单ID但它不起作用.在magento 1.x中,我们可以使用相同的方法轻松地从结账会话中获取订单ID.在magento 2.x中,我们无法做到这一点.
在magento 2.x如何在成功页面之前在访客结账中获取订单ID?
任何帮助,将不胜感激.
谢谢