'product', 'posts_per_page' => '-1');
$combined = array();
$getproducts = get_posts($args);
$newvariable = array();
if (is_array($getproducts)) {
foreach ($getproducts as $product) {
$product_type = get_product($product->ID);
if ($product_type->is_type('simple')) {
if (get_post_meta($product->ID, '_crowdfundingcheckboxvalue', true) != 'yes') {
$productids[] = $product->ID;
$producttitles[] = $product->post_title;
}
} else {
if ($product_type->is_type('variable')) {
if (is_array($product_type->get_available_variations())) {
foreach ($product_type->get_available_variations() as $getvariation) {
$productids[] = $getvariation['variation_id'];
$producttitles[] = get_the_title($getvariation['variation_id']);
}
}
}
}
}
}
if (is_array($productids) && is_array($producttitles)) {
@$combined = array_combine((array) $productids, (array) $producttitles);
}
// var_dump($combined);
wp_nonce_field(plugin_basename(__FILE__), 'cfperkrulenonce');
?>
";
// }
// }
//
// $j = 0;
// $perkrule = get_post_meta($post_id, 'perk', true);
// foreach ($perkrule as $perk) {
// foreach ($getperkprice as $price) {
// if ($perk['amount'] != (int) $price) {
// echo $length = count(array_keys($getperkprice, (int) $price));
// $claimcount = get_post_meta($post_id, 'perk[' . $j . '][claimcount]', true);
// $currentcount = get_post_meta($post_id, 'perk[' . $j . '][update_perk_claim]', true);
// if ($claimcount > $currentcount) {
// // delete_post_meta($post_id, 'perk[' . $j . '][update_perk_claim]');
// }
// }
// }
// $j++;
// }
}
public static function cf_perk_rule_front_end() {
global $post;
global $woocommerce;
$perkrule = get_post_meta($post->ID, 'perk', true);
$i = 0;
$getperkprice = array();
if (is_array($perkrule)) {
?>
ID, '_crowdfundingcheckboxvalue', true) == 'yes') {
?>
$perk) {
$perk['amount'] = woocs_convert($perk['amount']);
$perkname = str_replace('', '_', $perk['name']);
//echo $newcounterclaim = (int) get_post_meta($post->ID, $perkname . '[update_perk_claim]', true);
$newcounterclaim = (int) get_post_meta($post->ID, $perkname . $perk['amount'] . 'update_perk_claim', true);
$targetclaim = $perk['claimcount'];
$is_unlimited = $perk['limitperk'];
//var_dump($targetclaim);
if ($is_unlimited == 'cf_limited') {
if (($targetclaim > $newcounterclaim) && ($targetclaim != '')) {
?>
ID, $newperkname . $perk['amount'] . 'update_perk_claim', true);
if ($newcounter == '') {
$newcounter = 0;
} else {
$newcounter = $newcounter;
}
echo $newcounter;
?>
claimed out of
ID, 'perk', true);
$i = 0;
$getperkprice = array();
if (is_array($perkrule)) {
?>
ID, '_crowdfundingcheckboxvalue', true) == 'yes') {
?>
$perk) {
$perk['amount'] = woocs_convert($perk['amount']);
$perkname = str_replace('', '_', $perk['name']);
//echo $newcounterclaim = (int) get_post_meta($post->ID, $perkname . '[update_perk_claim]', true);
$newcounterclaim = (int) get_post_meta($post->ID, $perkname . $perk['amount'] . 'update_perk_claim', true);
$targetclaim = $perk['claimcount'];
$is_unlimited = $perk['limitperk'];
//var_dump($targetclaim);
if ($is_unlimited == 'cf_limited') {
if (($targetclaim > $newcounterclaim) && ($targetclaim != '')) {
?>
ID, $newperkname . $perk['amount'] . 'update_perk_claim', true);
if ($newcounter == '') {
$newcounter = 0;
} else {
$newcounter = $newcounter;
}
echo $newcounter;
?>
claimed out of
";
var_dump($listofamount);
$perkrule = get_post_meta($post->ID, 'perk', true);
$i = 0;
foreach ($perkrule as $perk) {
foreach ($listofamount as $amount) {
if ($perk['amount'] == (int) $amount) {
$length = count(array_keys($listofamount, (int) $amount));
$claimcount = (int) $perk['claimcount'];
$perkquantity = (int) $listquantity[$i];
echo $perkquantity . "
";
$quantitylog[] = $perk['name'] . ' x ' . $perkquantity;
$perkname = str_replace('', '_', $perk['name']);
// $currentcount = (int) get_post_meta($item['product_id'], $perkname . $perk['amount'] . 'update_perk_claim', true);
if ($claimcount > $currentcount) {
// update_post_meta($item['product_id'], $perkname . $perk['amount'] . 'update_perk_claim', $length + $currentcount);
}
$i++;
}
}
}
}
public static function galaxyfunder_sessionhandler($order_id, $order_posted) {
session_start();
$sessionname = "";
$sessionproduct = "";
$sessionprice = "";
$perkname = "";
$listamount = "";
$perkchoosedproduct = "";
$explodequantity = "";
$order = new WC_Order($order_id);
// var_dump($order->get_items());
foreach ($order->get_items() as $item) {
if (isset($_SESSION['perkcontainer' . $item['product_id']])) {
$sessionname = $_SESSION['perkcontainer' . $item['product_id']];
}
if (isset($_SESSION['productid' . $item['product_id']])) {
$sessionproduct = $_SESSION['productid' . $item['product_id']];
}
if (isset($_SESSION['amount' . $item['product_id']])) {
$sessionprice = $_SESSION['amount' . $item['product_id']];
}
if (isset($_SESSION['perkname' . $item['product_id']])) {
$perkname = $_SESSION['perkname' . $item['product_id']];
}
if (isset($_SESSION['listamount' . $item['product_id']])) {
$listamount = $_SESSION['listamount' . $item['product_id']];
}
if (isset($_SESSION['choosedproduct' . $item['product_id']])) {
$perkchoosedproduct = $_SESSION['choosedproduct' . $item['product_id']];
}
if (isset($_SESSION['explodequantity' . $item['product_id']])) {
$explodequantity = $_SESSION['explodequantity' . $item['product_id']];
}
if (isset($_SESSION['listiteration' . $item['product_id']])) {
$listofiteration = $_SESSION['listiteration' . $item['product_id']];
}
if (isset($_SESSION['getlistofquantities' . $item['product_id']])) {
$qtyiteration = $_SESSION['getlistofquantities' . $item['product_id']];
}
update_post_meta($order_id, 'perkname' . $item['product_id'], $perkname);
update_post_meta($order_id, $sessionname, $sessionprice);
update_post_meta($order_id, "perk_maincontainer" . $item['product_id'] . $order_id, $sessionproduct);
update_post_meta($order_id, 'perk_choosed_product' . $item['product_id'], $perkchoosedproduct);
update_post_meta($order_id, 'getlistofquantities', $qtyiteration);
update_post_meta($order_id, 'listiteration', $listofiteration);
update_post_meta($order_id, 'perk_list_amount' . $item['product_id'], $listamount);
update_post_meta($order_id, 'explodequantity' . $item['product_id'], $explodequantity);
}
session_destroy();
}
}
add_action('woocommerce_checkout_update_order_meta', array('CFPerkMetaBox', 'galaxyfunder_sessionhandler'), 10, 2);
//add_action('wp_head', array('CFPerkMetaBox', 'getvalueinarray'));
//add_action('woocommerce_after_single_product_summary', array('CFPerkMetaBox', 'cf_perk_rule_front_end'));
$cf_perk_showhide = get_option('cf_perk_table_show_hide');
if ($cf_perk_showhide == 1) {
if (get_option('cf_perk_table_position') == '1') {
add_action('woocommerce_before_single_product_summary', array('CFPerkMetaBox', 'cf_perk_rule_front_end'));
} elseif (get_option('cf_perk_table_position') == '2') {
add_action('woocommerce_after_single_product', array('CFPerkMetaBox', 'cf_perk_rule_front_end'));
} else {
add_action('woocommerce_after_single_product_summary', array('CFPerkMetaBox', 'cf_perk_rule_front_end'));
}
}
add_action('add_meta_boxes', array('CFPerkMetaBox', 'add_perk_meta_box'));
add_action('save_post', array('CFPerkMetaBox', 'perk_save_dynamic_data'));
add_shortcode('displayperk', array('CFPerkMetaBox', 'cf_perk_rule_front_end_shortcode'));
add_action('wp_ajax_nopriv_selectperkoption', array('CFPerkMetaBox', 'galaxy_funder_update_perk_rule'));
add_action('wp_ajax_selectperkoption', array('CFPerkMetaBox', 'galaxy_funder_update_perk_rule'));
?>