Salesforce ids / shipping method

Get salesforce ids from ACF. Add salesforce id input to shipping methods.
This commit is contained in:
Tony Volpe
2024-08-09 16:25:48 +00:00
parent 36dc023d6d
commit 5aeaa55a05
2 changed files with 48 additions and 8 deletions

View File

@@ -510,6 +510,37 @@ if (is_iterable($_SESSION["addOns"])) {
}
}
// addons salesforce ID
$falldetection_sfid = $_SESSION["addOns"]["Fall Detection"]["salesforce_id"];;
$protectionplan_sfid = $_SESSION["addOns"]["Protection Plan"]["salesforce_id"];
// Method to access protected property
function get_protected_property($object, $property) {
$reflection = new ReflectionClass($object);
$property = $reflection->getProperty($property);
$property->setAccessible(true);
return $property->getValue($object);
}
// Get the SKU from the protected parent_data property
$parent_data = get_protected_property($cart_item['data'], 'parent_data');
$sku = $parent_data['sku']; // Salesforce ProductID
$rate_plan_sfid = $cart_item['variation']['attribute_rate-plan-sfid']; // Product rate plan salesforce ID
$product_id = $cart_item['product_id'];
$accessories = get_field( 'accessories', $product_id );
foreach ($accessories as $accessory) {
// Sanitize the accessory to create a valid PHP variable
$sanitized_name = strtolower(str_replace(' ', '_', $accessory["accessory_name"]));
// Assigning values to individual variables for each accessory
$accessories_name = ${$sanitized_name . '_name'} = $accessory['accessory_name'];
$accessories_sfid = ${$sanitized_name . '_salesforce_id'} = $accessory['salesforce_id'];
$accessories_price = ${$sanitized_name . '_price'} = $accessory['price'];
//var_dump($accessories_name);
//$accessories_sfid = ${$sanitized_name . '_salesforce_id'};
}
$proinstall_label = $_SESSION["one-time"]["Professional Install"]["label"];
$fees = WC()->cart->get_fees();
@@ -607,8 +638,6 @@ if ($is_sixforsix_applied || $is_fiveoff_applied) {
"totalMonthly" => $monthlyCosts,
"activationFeeName" => $activationFeeName,
"activationFeeAmount" => $oneTimeCostsFee,
"programming_fee_name" => $programming_fee_name,
"programming_fee_val" => $programming_fee_val,
"totalDue" => $total_cart,
"showCheckoutButton" => $showCheckoutButton,
"couponSummary" => $couponSummary,
@@ -1303,3 +1332,20 @@ function customize_billing_fields($fields) {
return $fields;
}
add_action('woocommerce_init', 'woocommerce_shipping_instances_form_fields_filters');
function woocommerce_shipping_instances_form_fields_filters(){
foreach( WC()->shipping->get_shipping_methods() as $shipping_method ) {
add_filter('woocommerce_shipping_instance_form_fields_' . $shipping_method->id, 'shipping_methods_additional_custom_field');
}
}
function shipping_methods_additional_custom_field( $settings ) {
$settings['shipping_comment'] = array(
'title' => __('Salesforce ID', 'woocommerce'),
'type' => 'text',
'placeholder' => __( 'Enter any additional comments for this shipping method.', 'woocommerce' ),
);
return $settings;
}

View File

@@ -11,12 +11,6 @@
<p>Service</p>
<p>{{#currencyFormatter variable_price}}</p>
</div>
{{#if programming_fee_name}}
<div class="d-flex justify-content-between">
<p>{{programming_fee_name}}</p>
<p>{{#currencyFormatter programming_fee_val}}</p>
</div>
{{/if}}
{{#if fallDetectionLabel}}
<div class="d-flex justify-content-between">