83 lines
2.5 KiB
PHP
83 lines
2.5 KiB
PHP
<?php
|
|
|
|
if (defined('PANTHEON_ENVIRONMENT') && (PANTHEON_ENVIRONMENT !== 'live')) {
|
|
|
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php';
|
|
global $wpdb;
|
|
|
|
update_option( 'select-environment', 'staging' );
|
|
update_option( 'id_api_salesforce', 'https://connectamerica--full.sandbox.my.salesforce-sites.com/RestServices/services/apexrest/');
|
|
|
|
$variation_id = 25524;
|
|
$post_id = 25523;
|
|
$product = wc_get_product( $post_id );
|
|
$attributes = array();
|
|
$attributes_arr = array(
|
|
|
|
array(
|
|
'name' => 'Price',
|
|
'options' => array( '0.00', '24.95', '44.95' ),
|
|
'position' => 0,
|
|
'visible' => false,
|
|
'variation' => true,
|
|
),
|
|
|
|
array(
|
|
'id' => wc_attribute_taxonomy_id_by_name( 'Mehtod' ),
|
|
'name' => 'Method',
|
|
'options' => array( 'Ground', 'One Day', 'Two Day' ),
|
|
'position' => 1,
|
|
'visible' => false,
|
|
'variation' => true,
|
|
),
|
|
array(
|
|
'id' => wc_attribute_taxonomy_id_by_name( 'sf_ID' ),
|
|
'name' => 'sf_ID',
|
|
'options' => array( 'a4t1I000000PaZMQA0', 'a4t8C000000HmrpQAC', 'a4t8C000000HmruQAC', 'a4t3s000000pYVaAAM', 'a4t3s000000pYVVAA2'),
|
|
'position' => 1,
|
|
'visible' => false,
|
|
'variation' => true,
|
|
)
|
|
);
|
|
|
|
|
|
if( $attributes_arr ){
|
|
foreach( $attributes_arr as $value ) {
|
|
$attribute = new WC_Product_Attribute();
|
|
if( isset( $value['id'] ) ){
|
|
$attribute->set_id( $value['id'] );
|
|
}
|
|
$attribute->set_name( $value['name'] );
|
|
$attribute->set_options( $value['options'] );
|
|
$attribute->set_position( $value['position'] );
|
|
$attribute->set_visible( $value['visible'] );
|
|
$attribute->set_variation( $value['variation'] );
|
|
$attributes[] = $attribute;
|
|
}
|
|
}
|
|
|
|
$product->set_attributes( $attributes );
|
|
|
|
$product->save();
|
|
|
|
$var_25524 = 25524;
|
|
$variation_25524 = new WC_Product_Variation();
|
|
$variation_25524 = wc_get_product_object( 'variation', $var_25524 );
|
|
$variation_25524->set_attributes(array('price' => '0.00','method' => 'Ground','sf_ID' => 'a4t1I000000PaZMQA0'));
|
|
$variation_25524->save();
|
|
|
|
$var_25525 = 25525;
|
|
$variation_25525 = new WC_Product_Variation();
|
|
$variation_25525 = wc_get_product_object( 'variation', $var_25525 );
|
|
$variation_25525->set_attributes(array('price' => '24.95','method' => 'Ground','sf_ID' => 'a4t8C000000HmrpQAC'));
|
|
$variation_25525->save();
|
|
|
|
$var_25527 = 25527;
|
|
$variation_25527 = new WC_Product_Variation();
|
|
$variation_25527 = wc_get_product_object( 'variation', $var_25527 );
|
|
$variation_25527->set_attributes(array('price' => '44.95','method' => 'One Day','sf_ID' => 'a4t8C000000HmruQAC'));
|
|
$variation_25527->save();
|
|
|
|
|
|
}
|