public?function?create_shipping_for_order_and_cart($order,?$cart)
????{???
????????global?$fs_package_id;
????????//?Check?if?the?cart?is?null?and?log?an?error?if?it?is.
????????if?(is_null($cart))?{
????????????error_log('Cart?is?null.?Cannot?proceed?with?creating?shipping?for?order.');
????????????return;?//?Exit?the?function?if?the?cart?is?null
????????}
????????//?Get?shipping?methods?from?the?order
????????$order_shipping_methods?=?$order->get_shipping_methods();
????????//?Get?shipping?packages?from?the?cart
????????$packages?=?$cart->get_shipping_packages();
????????$current_package?=?-1;
????????foreach?($order_shipping_methods?as?$shipping_id?=>?$shipping_method)?{
????????????$current_package++;
????????????//?Get?the?package?ID?based?on?the?current?package?index
????????????$package_id?=?array_keys($packages)[$current_package];
????????????$fs_package_id?=?$package_id;
????????????//?Retrieve?the?shipping?method?details
????????????$fs_method?=?$this->get_fs_method_from_order_shipping_method($shipping_method);
????????????if?(!empty($fs_method['method_integration']))?{
????????????????$integration?=?$fs_method['method_integration'];
????????????????//?Check?if?the?shipment?integration?exists?and?is?supported?by?the?order?type
????????????????if?(fs_shipment_integration_exists($integration)?&&?$this->is_order_type_supported_by_integration($order->get_type(),?$integration))?{
????????????????????//?Create?a?shipment?for?the?order?and?the?shipping?method
????????????????????$shipment?=?$this->create_shipment_for_order_and_fs_shipping_method($order,?$fs_method,?$shipping_id,?$shipping_method,?$packages,?$package_id);
????????????????????/**
????????????????????*?Do?actions?when?shipment?is?created?via?checkout.
????????????????????*
????????????????????*?@param?\WPDesk_Flexible_Shipping_Shipment?$shipment?Created?shipment.
????????????????????*/
????????????????????do_action('flexible_shipping_checkout_shipment_created',?$shipment);
????????????????}
????????????}
????????}
????}
i change this function and working successfully