Created
September 27, 2019 17:40
-
-
Save hmaesta/652f51fde24539d14092922e7d44d74f to your computer and use it in GitHub Desktop.
Como configurar uma página de upsell usando Appmax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Antes de começar, adicione as possibilidades de | |
* upsell pela página: https://admin.appmax.com.br/my-upsell | |
* | |
* No campo "URL página de Upsell" preencha sua | |
* URL no formato: site.com.br/este-arquivo.php?order_bundle_id={order_bundle_id} | |
* | |
* Obviamente você pode colocar outros parâmetros, | |
* mas seguindo este modelo é obrigatório configurar | |
* o parâmetro `order_bundle_id={order_bundle_id}` | |
* | |
* Ao final do arquivo, não esqueça de setar | |
* seu TOKEN. | |
* Vá em https://admin.appmax.com.br/my-upsell | |
* clique em qualquer um dos upsells criados | |
* e clique no botão "Instruções de uso" | |
*/ | |
/* | |
* ID do bundle comprado pelo usuário | |
*/ | |
$order_bundle_id = $_GET['order_bundle_id']; | |
/* | |
* Se o usuário comprou o bundle 1234, | |
* oferece o bundle 1111 como upsell | |
*/ | |
if ($order_bundle_id === '1234') { | |
$upsell_bundle_id = "1111"; | |
$upsell_unit_price = "R$ 10,00"; // preço do bundle oferecido como upsell | |
$upsell = true; | |
} | |
/* | |
* Se o usuário comprou o bundle 5678, | |
* oferece o bundle 2222 como upsell | |
*/ | |
else if ($order_bundle_id === '5678') { | |
$upsell_bundle_id = "2222"; | |
$upsell_unit_price = "R$ 8,00"; // preço do bundle oferecido como upsell | |
$upsell = true; | |
} | |
/* | |
* Se o usuário comprou um bundle | |
* que não é nem 1234 e nem 5678 | |
* não mostra upsell | |
*/ | |
else { | |
$upsell = false; | |
} | |
?> | |
<!doctype html> | |
<html lang="pt"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" | |
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Compra com upsell Appmax</title> | |
<link rel="stylesheet" type="text/css" href="https://cdn.appmax.com.br/css/withoutboostrap.min.css"> | |
<link rel="stylesheet" type="text/css" href="https://cdn.appmax.com.br/js/jquery-confirm.min.css"> | |
</head> | |
<body> | |
<h1>Obrigado pela sua compra!</h1> | |
<?php if ($upsell) : ?> | |
<div> | |
<h2>Compre mais uma unidade</h2> | |
<div class="preco"> | |
Por apenas <?php echo $upsell_unit_price; ?> | |
</div> | |
<button type="button" data-bundle="<?php echo $upsell_bundle_id; ?>"> | |
Comprar! | |
</button> | |
</div> | |
<?php endif; ?> | |
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script> | |
<script src="https://cdn.appmax.com.br/js/one-click-upsell.min.js"></script> | |
<script src="https://cdn.appmax.com.br/js/jquery-confirm.min.js"></script> | |
<script type="text/javascript"> | |
const TOKEN = "1234-1234-1234-1234"; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment