magento2 – How to show customer data ( name, surname, address ) on my custom checkout step after shipping step?

I have created custom checkout step after shopping step.
Now i need to show there customer’s information from shipping step (first name, last name, address, city, country, phone number, etc ) and his orders ( name of order and quantity ).
I don’t know how to do it, please give any advices.

magento2.3.5 – using customer session in block

I want to get customer id in block but the customer session returns null.

from controller, i could get customer id.

logger in block works well so the customer id is executed.

vendor/Block/Config.php

class Config extends MagentoFrameworkViewElementTemplate                                                                                                                                       
{
    public function __construct(
        MagentoFrameworkViewElementTemplateContext $context,
        MagentoCustomerModelSession $customerSession
    ) {
        $this->session = $customerSession;
        $this->logger = $logger;

        parent::__construct($context);
    }

    /**
     */
    public function getCustomerId(): int
    {
        $this->logger->debug('this log is ok');
        return $this->session->getCustomer()->getId(); // return null
    }

from view,
<?=$block->getCustomerId();?>

this code returns 500 because the type hinting of getCustomerId() is :int and return null.

this->session->getCustomer returns null

this->session->isLoggedIn also returns null

i saw almost same, other question in stackexchange, they do not fit my ploblem.

like this Magento2 error on injecting customer session in block

ofcourse i did

setup:upgrade

setup:di:compile

cache:celan

database design – Data modelling and openAPI3.0 for customer and license management – when to know how to split entities?

I’m working on a unique ERP + Ecommerce which is a mix of “Shopify meets Adobe Cloud admin”.
Current project: ancient php framework with MVC, no architecture, resembles a procedural website
Refactor objective: switch architecture to MVVM using OpenAPI to generate proxy classes

When redesigning with OpenAPI and doing database normalization
How entities should be separated from each other?

Entity:

Company
Account Owner
Account Member
License Ownership
License Assigment (in use like a seat)
Shipping Address
Shipping Country
Taxes
Billing Address

How should I structure the openapi and database model?
In the case of taxes, for example, I need to know all of these

    "Province_State_Tax_Id": "1",
    "Province_State_Name": "Alberta",
    "Province_State_Abbreviation": "AB",
    "Province_State_Tax": "5.00",
    "Country_Id": 38

But I also need to query extra things such as who is the owner of the account, but at the same time maintaining the organization separated from owner (that person could leave the company if it’s an employee). I have functions such as license transfer from one account to another, dealers.

Should I make all those parts separate, then compose them together? When to know when it’s too much separation and too little?

magento2.3.4 – Magento 2 – Disable Payment Method for Certain Customer Groups by using Observer

Source : https://www.magedelight.com/resources/how-to-disable-payment-method-for-certain-customer-groups-in-magento-2/ Stright opposite i just enable certain customer group,

app/code/Gta/EnablePaymentMethod/registration.php

<?php
MagentoFrameworkComponentComponentRegistrar::register(
    MagentoFrameworkComponentComponentRegistrar::MODULE,
    'Gta_EnablePaymentMethod',
    __DIR__
);

app/code/Gta/EnablePaymentMethod/etc/events.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="payment_method_is_active">
        <observer name="enable_payment_customer_group" instance="GtaEnablePaymentMethodObserverPaymentMethodEnable" />
    </event>
</config>

app/code/Gta/EnablePaymentMethod/etc/module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Gta_EnablePaymentMethod" setup_version="1.0.0" schema_version="1.0.0"/>
</config>

app/code/Gta/EnablePaymentMethod/Observer/PaymentMethodEnable.php

<?php
namespace GtaEnablePaymentMethodObserver;
use MagentoFrameworkEventObserver;
use MagentoFrameworkEventObserverInterface;
class PaymentMethodEnable implements ObserverInterface {
    protected $_customerSession;
    public function __construct(
       MagentoCustomerModelSession $customerSession
    ) {
       $this->_customerSession = $customerSession;
    }
    public function execute(Observer $observer) {
       $payment_method_code = $observer->getEvent()->getMethodInstance()->getCode();
       if ($payment_method_code == 'paypal_express') {
           $result = $observer->getEvent()->getResult();
           if ($this->_customerSession->isLoggedIn()) {
               $customerGroupId = $this->_customerSession->getCustomer()->getGroupId();
               if ($customerGroupId == 9) {
                   $result->setData('is_available', true);
               }
           }
       }
    }
}

Anything else i forget to do?

Cloudarion.com – #1 SSDVPS hosting – 100% Customer Satisfaction! | Proxies-free

https://cloudarion.com/ service is the perfect solution.

Cloudarion has been a major presence in the Web Hosting market since 2011. All of our staff is in-house and we pride ourselves on operating our own networks and infrastructures. If you add our high quality to the potency of SSDVPS hosting, you will receive a winning package. We have always been proud of our 99.9% uptime on VPS systems.

Check out Cloudarion SSDVPS hosting packages:

SSDVPS 2 hosting plan
RAM – 2 Gb
SSD – 20 Gb
OS – Windows server, CentOS, Debian, Linuxmint, Scilinux or Ubuntu.
Price $20/month

SSDVPS 4 hosting plan
RAM – 4 Gb
SSD – 30 Gb
OS – Windows server, CentOS, Debian, Linuxmint, Scilinux or Ubuntu.
Price $40/month

Payment methods accepted: Paypal, Payza, Bitcoin, WebMoney, Payoneer.

Hard drives are in a RAID 10 redundant array to ensure your data remains safe!
Local and Backup on remote server! Your VPS container will be on local RAID-10 Storage Array’s for the fastest & most reliable storage architecture for your websites. RAID-10 technology offer a staggering boost in input/output operations per second (IOPS).

Need help? Contact with our technical support.

 

javascript – Finds customer who live within 100km and output them to a text file

I had an interview task where I had to output customers who live 100km within a particular latitude and longitude and then output them to a file with their username and ID. The customer file looks like the following:

{"latitude": "52.986375", "user_id": 12, "name": "Christina McArdle", "longitude": "-6.043701"}
{"latitude": "51.92893", "user_id": 1, "name": "Alice Cahill", "longitude": "-10.27699"}
{"latitude": "51.8856167", "user_id": 2, "name": "Ian McArdle", "longitude": "-10.4240951"}
{"latitude": "52.3191841", "user_id": 3, "name": "Jack Enright", "longitude": "-8.5072391"}

Here is the code to implement the calculation for the great-circle-distance

/**
 * solution accuired from
 * https://www.movable-type.co.uk/scripts/latlong.html
 */

const greatCircleDistanceCalc = (lat1, lon1, lat2, lon2) => {
  const R = 6371; // Radius of the earth in km
  const dLat = deg2rad(lat2 - lat1); // deg2rad below
  const dLon = deg2rad(lon2 - lon1);
  const a =
    Math.sin(dLat / 2) * Math.sin(dLat / 2) +
    Math.cos(deg2rad(lat1)) *
      Math.cos(deg2rad(lat2)) *
      Math.sin(dLon / 2) *
      Math.sin(dLon / 2);
  const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
  const d = R * c; // Distance in km
  return d;
};

const deg2rad = (deg) => {
  return deg * (Math.PI / 180);
};

module.exports = {
    greatCircleDistanceCalc,
}; 

Here is the main app.js where the calculation is used and a customer file is read and a new file is outputted.

const fs = require("fs");
const { greatCircleDistanceCalc } = require("./greatCircleDistanceCalc.js");

const customerFile = fs.readFileSync("./customers.txt", "utf-8"); //Read in file
const customerArr = customerFile.split("n").map((s) => JSON.parse(s)); //Convert file into array of objects

const dublinOffice = {
  latitude: "53.339428",
  longitude: "-6.257664",
};

const invitedArr = ();

//Sort data in ascending order
const sortedCustomers = customerArr.sort((a, b) => {
  return a.user_id - b.user_id;
});

const closestCustomers = (sortedCustomers, arr) => {
  for ({ latitude, longitude, user_id, name } of sortedCustomers) {
    if (
      greatCircleDistanceCalc(
        dublinOffice.latitude,
        dublinOffice.longitude,
        latitude,
        longitude
      ) <= 100
    ) {
      invitedArr.push(`${name}:${user_id}`);
    }
  }
  writeInvitedCustomer(arr);
};

const writeInvitedCustomer = (arr) => {
  const writeStream = fs.createWriteStream("Output.txt");
  const pathName = writeStream.path;

  arr.forEach((value) => writeStream.write(`${value}n`));
  writeStream.on("finish", () => {
    console.log(`wrote all the array data to file ${pathName}`);
  });

  writeStream.on("error", (err) => {
    console.error(`There is an error writing the file ${pathName} => ${err}`);
  });

  writeStream.end();
};

closestCustomers(sortedCustomers, invitedArr);

Overall I am happy with the solution but I think the only thing is I am not sure how to write a test for this.

As always any feedback and suggestions are much welcome.

magento2.3.3 – Get Latest Ordered Items for a Customer Across Multiple Orders

I am trying to gather the latest 100 items a customer has purchased across all his orders. I know I can use itemCollectionFactory and go order by order, but I was wondering if there is a faster way to get directly all the items, instead of running multiple queries for each order.

With a single query, I’d also be able to make sure the same items are not shown twice in the list.

Thanks!

I will provide active insurance customer targeted b2b lead service for $1

I will provide active insurance customer targeted b2b lead service

Hi, Welcome to my Gig,

I am a professional expert Computer Operator. I am offer high quality lead services. My unique selling proposition is high quality work as per the expectations of client and i am always deliver on time. I am also develop detailed professional report share with clients.

I will give you 100% active verified email list & targeted leads.

I will supply you with the following on EVERY LIST:

  1. Fist & Last Name
  2. Email (Active)
  3. Address
  4. City
  5. State
  6. Country
  7. Phone Number
  8. Date of Birth (DOB)

All leads are HIGH QUALITY, ACTIVE and up to date.

Why me?

>> Professional and efficient work

>> 100% delivery on time

>> high quality & error-free work

>> client satisfaction is a priority

>> Money back guaranty.

## I can work to your satisfaction.

ORDER NOW and grow your business quickly.

Best Regards;

Abul Bahser

.(tagsToTranslate)leadgeneration(t)b2b(t)emailaddress(t)businessifo(t)targetedniche