Good day people,
I have been trying to change the required field of lastname as not required in the form in the billing address of the checkout page:
As you can see the field of lastname is out and I used just Company name.
The things that I tried up until now are these:
to the talons/CheckoutPage/BillingAddress/useBillingAddress.js
I erased the value lastname from the setBillingAddress & updateBillingAddress:
const setBillingAddress = useCallback(() => {
const {
firstName,
country,
street1,
street2,
city,
region,
postcode,
phoneNumber
} = formState.values;
updateBillingAddress({
variables: {
cartId,
firstName,
country,
street1,
street2,
city,
region,
postcode,
phoneNumber,
sameAsShipping: false
}
});
}, [formState.values, updateBillingAddress, cartId]);
to the talons/CheckoutPage/BillingAddress/billingAddress.gql.js
I did the same:
export const SET_BILLING_ADDRESS = gql`
mutation setBillingAddress(
$cartId: String!
$firstName: String!
$street1: String!
$street2: String
$city: String!
$region: String!
$postcode: String!
$country: String!
$phoneNumber: String!
) {
setBillingAddressOnCart(
input: {
cart_id: $cartId
billing_address: {
address: {
firstname: $firstName
street: [$street1, $street2]
city: $city
region: $region
postcode: $postcode
country_code: $country
telephone: $phoneNumber
save_in_address_book: false
}
}
}
) @connection(key: "setBillingAddressOnCart") {
cart {
id
billing_address {
firstname
country {
code
}
street
city
region {
code
}
postcode
telephone
}
...PriceSummaryFragment
...AvailablePaymentMethodsFragment
}
}
}
${PriceSummaryFragment}
${AvailablePaymentMethodsFragment}
`;
I also change the is_required = 0
in the table eav_attribute
, entity_type_id = 2
And finally I tried to comment the value of lastname in the schema CartAddressInput in my new module, the route of my module is this: /app/code/MyCompany/AdminUserForms/etc/schema.graphqls
the route of original module is this: vendor/magento/module-quote-graph-ql/etc/schema.graphqls
This is the schema:
input CartAddressInput
@doc(
description: "Defines the billing or shipping address to be applied to the cart."
) {
firstname: String!
@doc(description: "The first name of the customer or guest.")
# lastname: String!
# @doc(description: "The last name of the customer or guest.")
company: String
@doc(
description: "The company specified for the billing or shipping address."
)
street: [String!]!
@doc(
description: "An array containing the street for the billing or shipping address."
)
city: String!
@doc(
description: "The city specified for the billing or shipping address."
)
region: String
@doc(
description: "A string that defines the state or province of the billing or shipping address."
)
region_id: Int
@doc(
description: "An integer that defines the state or province of the billing or shipping address."
)
postcode: String
@doc(
description: "The ZIP or postal code of the billing or shipping address."
)
country_code: String!
@doc(
description: "The country code and label for the billing or shipping address."
)
telephone: String
@doc(
description: "The telephone number for the billing or shipping address."
)
save_in_address_book: Boolean
@doc(
description: "Determines whether to save the address in the customer's address book. The default value is true."
)
}
I did all of this and I getting the same error:
Does anyone have any solution for this?