function paypal_cart_items() { session_start(); $html = ''; if (isset($_SESSION['cart']) && !empty($_SESSION['cart'])) { $sub_total = 0; $count = 0; foreach ($_SESSION['cart'] as $id => $qty) { $count++; $attribute = FALSE; $prodid = explode('/', $id); $item = get_post($prodid[0]); $price = get_field('price', $prodid[0], TRUE); if (count($prodid) == 2) { $attribute = get_product_attribute($prodid[0], $prodid[1]); $price = $attribute['price']; } $sub_total = $sub_total + $price * $qty; if (is_array($attribute) && !empty($attribute)) { if ($attribute['product_type'] == 'variable') { $html .= '<input type="hidden" name="item_name_' . $count . '" value="' . $item->post_title . ' :: ' . $attribute['attribute_name'] . '">'; } else { if ($attribute['product_type'] == 'linked') { $html .= '<input type="hidden" name="item_name_' . $count . '" value="' . $item->post_title . ' + ' . $attribute['attribute_name'] . '">'; } } } else { $html .= '<input type="hidden" name="item_name_' . $count . '" value="' . $item->post_title . '">'; if (get_field('product_type', $id, TRUE) == 'combo') { $html .= '<input type="hidden" name="on0_' . $count . '" value="Your Chioce">'; $html .= '<input type="hidden" name="os0_' . $count . '" value="' . $_SESSION['combo']['your_choice_value'] . '">'; $html .= '<input type="hidden" name="on1_' . $count . '" value="Chips">'; $html .= '<input type="hidden" name="os1_' . $count . '" value="' . $_SESSION['combo']['chips_value'] . '">'; $html .= '<input type="hidden" name="on2_' . $count . '" value="' . $_SESSION['combo']['only_one'] . '">'; $html .= '<input type="hidden" name="os2_' . $count . '" value="' . $_SESSION['combo']['only_one_value'] . '">'; } } if (isset($_SESSION['burger_note'])) { if (isset($_SESSION['burger_note'][$id])) { $html .= '<input type="hidden" name="on3_' . $count . '" value="Additional Note">'; $html .= '<input type="hidden" name="os3_' . $count . '" value="' . $_SESSION['burger_note'][$id] . '">'; } } $html .= '<input type="hidden" name="quantity_' . $count . '" value="' . $qty . '">'; $html .= '<input type="hidden" name="amount_' . $count . '" value="' . $price . '">'; $html .= '<input type="hidden" name="item_number_' . $count . '" value="' . $id . '">'; } } return $html; }
foreach ($_SESSION['cart'] as $id => $qty) { $attribute = FALSE; $linked_prod_class = ''; $linked_prod_attr_class = ''; $prodid = explode('/', $id); if (get_field('product_type', $id, TRUE) == 'linked') { $linked_product = TRUE; $linked_prod_class = 'linked_product_' . $id; } if (get_field('product_type', $prodid[0], TRUE) == 'linked') { $linked_prod_attr_class = 'linked_product_attribute_' . $prodid[0]; } $item = get_post($prodid[0]); $price = get_field('price', $prodid[0], TRUE); if (count($prodid) == 2) { $attribute = get_product_attribute($prodid[0], $prodid[1]); $price = $attribute['price']; } $msg .= '<tr>'; $msg .= '<td style="border: 1px solid #ccc; padding: 10px; text-align: center;">' . $item->post_title; if (is_array($attribute) && !empty($attribute)) { $msg .= '<ul class="specialDescLine ' . $linked_prod_attr_class . '">'; $msg .= '<li>' . $attribute['attribute_name'] . '</li>'; $msg .= '</ul>'; } if (get_field('product_type', $id, TRUE) == 'combo') { $msg .= '<ul class="combo">'; $msg .= '<li>Your Chioce : ' . $_SESSION['combo']['your_choice_value'] . '</li>'; $msg .= '<li>Chips : ' . $_SESSION['combo']['chips_value'] . '</li>'; $msg .= '<li>' . $_SESSION['combo']['only_one'] . ' : ' . $_SESSION['combo']['only_one_value'] . '</li>'; $msg .= '</ul>';